I have one class with a xaml which contains a label. I want to change content of this label from one different class.
for example i have a class mainwindow.xaml.cs with mainwindow.xaml and i want to handle the label of mainwindow.xaml from the newclass.cs.
How can i do this??
edit: i have this label in a grid and i want to change the content from another class:
<Label Content="" Panel.ZIndex="1" FontWeight="SemiBold" FontSize="16px" Name="lb1" Margin="0,0,0,0" VerticalAlignment="Bottom" Height="30" HorizontalAlignment="Right" Width="250" HorizontalContentAlignment="Right" VerticalContentAlignment="Top"/>
Data binding and MVVM would be the most elegant solution.
But you can simply use code-behind.
Give the label a name
<Label x:Name="myLabel">so you can access it in your code with that name like any other variable.You can then pass this variable to your newclass.cs and change its properties there.