I have a class called MyClass with a property called Density located in main window and binded to a textbox in another window called Material. I binded textbox with a property because, as far as I know, I cannot bind it with an instance. OK, now I want to use the instance, I mean I want to get instance Density when I close the Material dialog to use it for calculations. How can I do this?
EDIT: Added some code:
Main Window:
public class MyClass
{
private string num;
public string Density
{
get { return num; }
set { num = value; }
}
}
Material Window: Some portion of XAML:
<TextBox Height="23" HorizontalAlignment="Left" Margin="130,27,0,0" Name="txt_density" VerticalAlignment="Top" Width="85" Style="{StaticResource textStyleTextBox}" TextChanged="txt_density_TextChanged">
<TextBox.Text>
<Binding Path="Density" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<local:Float_Positive_ValidationRule/>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
Here I want to use density to make some calculations as I cannot do that with a class.
I’m making assumptions that your actual
Windowimplementation is called “Material” as implied by your post.UPDATE:
Edited after seeing your code.
In your calling code:
In your
Materialwindow code: