Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net Silverlight 4相对资源FindAncestor绑定_.net_Silverlight_Binding_Relativesource - Fatal编程技术网

.net Silverlight 4相对资源FindAncestor绑定

.net Silverlight 4相对资源FindAncestor绑定,.net,silverlight,binding,relativesource,.net,Silverlight,Binding,Relativesource,是否会有相对的资源查找或取消存储类型。。。在Silverlight 4中?在Silverlight 4中,绑定的相对资源属性仍然只支持“Self”和“TemplatedParent”,与Silverlight 3在这方面没有变化。这可能有助于: 也许您可以在XMAL中将ViewModel实例化为一个静态资源,然后在绑定中将其作为源引用 <UserControl.Resources> <vm:MainPageViewModel x:Key="ViewModel"/>

是否会有相对的资源查找或取消存储类型。。。在Silverlight 4中?

在Silverlight 4中,
绑定的
相对资源
属性仍然只支持“Self”和“TemplatedParent”,与Silverlight 3在这方面没有变化。

这可能有助于:


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

<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>

相对资源存储类型
,现在可用

<TextBlock Text="{Binding Name}" 
           FontSize="{Binding DataContext.CustomFontSize, 
               RelativeSource={RelativeSource AncestorType=UserControl}}"
/>