带DataTemplate的DynamicResource

时间:2011-07-11 16:24:28

标签: c# .net wpf xaml data-binding

UserControl需要执行一些多语言。在构造函数中,我使用ResourceDictionary动态加载适当的XAML。在那个XAML中我有:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:system="clr-namespace:System;assembly=mscorlib">
<system:String x:Key="somekey">Some Label</system:String></ResourceDictionary>

然后我

Header = {DynamicResource somekey}
DataTemplate中的DataGridTextColumn中的

也是UserControl使用的。看起来DataTemplate不知道新的ResourceDictionary。

但是,它不起作用。拜托,为什么?

1 个答案:

答案 0 :(得分:0)

我猜你应该绑定到标题内容。资源本身无法通知任何更改,因此绑定可能是解决方案。

Header={Binding Source={DynamicResource someKey}, Path=.}

无论如何我不确定:永远不要尝试这样的条件。

相关问题