Binding в C# WPF

Есть в главном окне label

<Label Grid.Row="0" Grid.Column="1" DataContext="{StaticResource h}" Content="{Binding Path=test}"/>

Binding - работает.

Есть в главном окне

<controls:uc x:Name="tttt" DataContext="{StaticResource h}" MyProperty="{Binding Path=test}"/>

Binding - НЕ работает.

Исходник uc

public int MyProperty
    {
        get { return (int)GetValue(MyPropertyProperty); }
        set { SetValue(MyPropertyProperty, value); lCaption.Content = value.ToString(); }
    }

    // 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(uc), new PropertyMetadata(0));

Почему не работает? С label всё отлично но если нужно сделать Binding к label в UserControl начинаются танцы с бубном и всё равно не работает.


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