Как сообщать об изменении в ViewModel в UserControl?

У меня во ViewModel имеется свойство

    private int numb;
    public int Numb
    {
        get => numb;
        set 
        {
            if (value != numb)
            {
                numb = value;
                OnPropertyChanged();
            }
        }
    }

UserControl, в котором есть свойство зависимости, в зависимости от которого изменяется количество строк в MyGrid

<UserControl x:Class="MyNamespace.MyUseControl"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:local="clr-namespace:MyNamespace"
         mc:Ignorable="d" 
         d:DesignHeight="500" d:DesignWidth="500">
<Grid Name="MyGrid">

</Grid>

Свойство зависимости, которое изменяется в зависимости от свойства Numb во ViewModel

public int MyProperty
    {
        get { return (int)GetValue(MyPropertyProperty); }
        set { SetValue(MyPropertyProperty, value); }
    }

    // Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty MyPropertyProperty =
        DependencyProperty.Register("MyProperty", typeof(int), typeof(MyUseControl), new PropertyMetadata(0));

Каким образом должна вызываться функция AddRow() в UserControl при изменении свойства Numb?

private void AddRow()
    {
        RowDefinitionCollection rd = MyGrid.RowDefinitions;
        rd.Clear();

        for (int i = 0; i < MyProperty; i++)
        {
            rd.Add(new RowDefinition());
        }
    }

Ответы (0 шт):