The UserControls
are put into MainWindow
but they don't instantiate each other - they don't have owner-member relationship.
I need the back-end code of UserControls
to be able to get the value from a TextBox
of MainWindow
. I have been told to use data binding but I don't really know what to be bound in UserControls
.
Create an interface:
interface Interface_ProSimIP
{
string ProSimIP_Text { get; set; }
}
In MainWindow
ViewModel:
string Interface_ProSimIP.ProSimIP_Text
{
get
{
return ProSimIP.Text;
}
set
{
}
}
In MainWindow
View:
<TextBox x:Name="ProSimIP" Text="{Binding Path=ProSimIP_Text, Mode=OneWay}..."
I don't know am I right to do it this way and I don't know how to implement the interface in UserControls
code behind.