开发者

Binding parent container props to content child control in Silverlight

Example:

<UserControl x:Name="userControl"
    <StackPanel x:Name="container" Margin="0">
        <TextBox Text="{Binding Path=SettingValue, RelativeSource={RelativeSourc开发者_如何学编程e 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?


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

 <TextBox Text="{Binding Path=SettingValue, ElementName=userControl"/>


The answer I've found here:

Binding Silverlight UserControl custom properties to its' elements

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜