I'm trying to change properties from a user control, And I would like to these properties to reflect in UI. But it's not working
Here is my class.
public class Note
{
public string Paper = "#FFFFFF";
public string Text = "";
}
Here is my control
<UserControl
x:Class="App.Controls.NoteControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="200"
d:DesignWidth="200">
<Grid Background="{Binding Path = Note.Paper, UpdateSourceTrigger=PropertyChanged}">
<!-- ... -->
</Grid>
</UserControl>
The control has a public Note
property
public sealed partial class NoteControl : UserControl {
public NoteControl() {
this.InitializeComponent();
}
public Note Note {
get { return (Note)GetValue(NoteProperty); }
set { SetValue(NoteProperty, value); }
}
public static readonly DependencyProperty NoteProperty =
DependencyProperty.Register("Note", typeof(Note), typeof(NoteControl), null);
}
In my MainWindow there is a simple code to update the Note
Property in my control.
MyNoteControl.Note = SomeNewNote;
What should I do in order to update the control's binding when changing the Note property?
Or maybe, there is another solution that can better address this issue?
Thanks