Reputation: 331460
I have a standard WPF app created using Visual Studio template. My MainWindow code looks like this:
public partial class MainWindow : Window
{
public MainWindow ( )
{
this.InitializeComponent ( );
}
string MyValue = "";
}
How can I bind my Label to MyValue using XAML?
Upvotes: 0
Views: 365
Reputation: 106
This is my .cs file :
public partial class MainWindow : Window
{
public MainWindow()
{
DataContext = this;
InitializeComponent();
}
public string MyValue { get; set; } = "Hello";
}
and my view file :
<Grid>
<Label Content="{Binding MyValue}"/>
</Grid>
Upvotes: 1