考虑下面的XAML代码:WPF绑定通过StaticResouces
<Window.Resources>
<System:String x:Key="StringValue"></System:String>
</Window.Resources>
<Grid>
<ComboBox Margin="137,101,169,183" ItemsSource="{Binding collection}" SnapsToDevicePixels="True" IsHitTestVisible="true">
<ComboBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<CheckBox Command="{Binding CheckCommand}" IsChecked="{Binding IsChecked}" Content="{Binding Name}"/>
<TextBlock Text="{StaticResource StringValue}" />
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</Grid>
我想是的文本块文本绑定到一个静态的资源,一个数据绑定到视图模型的值。问题是System.String似乎不允许数据绑定。任何人都知道如何做到这一点?对于上下文来说,TextBlock需要一个不同于其父组合框的itemSource。
谢谢。
你有别名** ** mscorlib程序? 'xmlns:System =“clr-namespace:System; assembly = mscorlib”'没有错误出现。 – 2011-06-10 08:37:24
是的,弦乐很好。 – 2011-06-10 08:37:58
看看我编辑一个可能的包装类,它允许检测字符串的更新 – fixagon 2011-06-10 09:17:05