首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Silverlight 4 RelativeSource FindAncestor绑定

Silverlight 4 RelativeSource FindAncestor绑定
EN

Stack Overflow用户
提问于 2010-02-19 02:55:00
回答 4查看 24.3K关注 0票数 21

会不会有RelativeSource FindAncestor,AncestorType...在Silverlight 4中?

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2010-02-19 05:24:33

在Silverlight4中,BindingRelativeSource属性仍然只支持"Self“和"TemplatedParent",这方面与Silverlight3没有什么不同。

票数 27
EN

Stack Overflow用户

发布于 2011-12-20 00:25:46

RelativeSource AncestorType is supported in Silverlight 5,现已推出。

代码语言:javascript
复制
<TextBlock Text="{Binding Name}" 
           FontSize="{Binding DataContext.CustomFontSize, 
               RelativeSource={RelativeSource AncestorType=UserControl}}"
/>
票数 16
EN

Stack Overflow用户

发布于 2010-10-08 19:48:39

也许您可以将XMAL中的ViewModel实例化为静态资源,然后在绑定中引用该资源作为源。

代码语言:javascript
复制
<UserControl.Resources>
    <vm:MainPageViewModel x:Key="ViewModel"/>
</UserControl.Resources>

<Grid x:Name="LayoutRoot" Background="White" DataContext="{Binding Source={StaticResource ViewModel}}">
    <ListBox ItemsSource="{Binding Partitions}">
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <toolkit:WrapPanel FlowDirection="LeftToRight"  />
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
        <ListBox.ItemTemplate>
            <DataTemplate>
                <Button Margin="10,0" Width="40" Content="{Binding}" Command="{Binding Source={StaticResource ViewModel}, Path=ButtonCommand}" CommandParameter="{Binding}"/>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>

</Grid>
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2291310

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档