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?
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.