Taras
Taras

Reputation: 1128

How to bind user's control label content to the custom dependency property

I'm trying to bind user's control label content to the custom dependency property. My dependency property is:

public static readonly DependencyProperty DayProperty =
        DependencyProperty.Register("Day", typeof(string), typeof(MultiSlider),   new UIPropertyMetadata("some"));

    public string Day
    {
        get { return (string)GetValue(DayProperty); }
        set { SetValue(DayProperty, value); }
    }

I want to get something like

<Label Content="{TemplateBinding Day}"/>

inside of my user control.

Upvotes: 1

Views: 1261

Answers (1)

Taras
Taras

Reputation: 1128

Solved by adding:

DataContext="{Binding RelativeSource={RelativeSource Self}}"

to my user control and then just:

<Label Content="{Binding Path=Day}"/>

Upvotes: 2

Related Questions