I have bound the Text
property of a TextBlock
in my UserControl
to one of its dependency properties (DPs), and the initial binding works properly and the text is displayed. However, when the FrameRate
property is updated later on, the change is not reflected in the TextBlock
.
Here is the code for the binding in the UserControl
:
<UserControl>
...
<TextBlock Text="{Binding UiView.FrameRate, RelativeSource={RelativeSource AncestorType=UserControl}}"/>
...
</UserControl>
public UiView UiView
{
get => (UiView)GetValue(s_uiViewProperty);
set => SetValue(s_uiViewProperty, value);
}
public static readonly DependencyProperty s_uiViewProperty = DependencyProperty.Register(
nameof(UiView), typeof(UiView), typeof(UiViewPanel), new PropertyMetadata(OnUiViewPropertyChanged));
And here is the code for the FrameRate
property, which is defined in the UiView
class:
private readonly FrameRate m_frameRate = new FrameRate();
public double FrameRate => m_frameRate.Current;
I am sure that the FrameRate
property is being updated, but the change is not reflected in the TextBlock
. How can I fix this issue and ensure that the updated value of FrameRate
is reflected in the TextBlock
?