views:

34

answers:

2

Example:

<UserControl x:Name="userControl"
    <StackPanel x:Name="container" Margin="0">
        <TextBox Text="{Binding Path=SettingValue, RelativeSource={RelativeSource Mode=Self}}"/>
    </StackPanel>
</UserControl>

UserControl contains SettingValue dependency property, TextBox doesn't, so this example won't work.

I could've done this if I had AncestorType, like in WPF:

RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControlType}

Is there any possibility to bind to UserControl.SettingValue property?

A: 

Did you try the following? Use the ElementName source (the syntax might be a bit off).

 <TextBox Text="{Binding Path=SettingValue, ElementName=userControl"/>
R4cOON
Yes, this will work, seems like the only way.
Dmitry
http://stackoverflow.com/questions/729689/binding-silverlight-usercontrol-custom-properties-to-its-elements/2711967#2711967
Dmitry