我想本地化一个演示文稿,并对此进行了大脑冻结。我使用的是标记扩展,因此而不是这样的:DataGridColumn标题内容WPF
<DataGridTextColumn Header="Number" Binding="{Binding Number}" Width="60" CellStyle="{StaticResource NumberStyle}" />
我想这一点:
<DataGridTextColumn Header="{Resx Key=Header_Number}" Binding="{Binding Number}" Width="60" CellStyle="{StaticResource NumberStyle}" />
其中的标记,这是很好的测试,将刚刚返回正确的文本当前文化。但它不起作用。我假设我需要HeaderStyle或HeaderTemplate,但是...
什么是修复?
干杯,
Berryl
编辑
通过不工作我的意思是没有返回文本“数字”,而在英语,而不是返回默认值(即,“# Header_Number)。
通过是的工作,我的意思是
<Label FontWeight="Bold" Grid.Row="0" Grid.Column="0" Content="{Resx Key=Label_Amount}"/>
用英语返回“金额”。
最后编辑
我的坏,这真是多的事实,WPF数据网格列不继承其父的DataContext的结果。
标记扩展有我喜欢为整个窗口设置一次ResxName属性:
resx:ResxProperty.Name="NMoneys.Presentation.Resources.AllocatorView"
Title="{Resx Key=Window_Title}"
但是,由于在数据网格的标头是不可视树的一部分(虽然它肯定似乎他们应该是!),我不得不再次明确把RESX的名称,如
<DataGridTextColumn Header="{Resx ResxName=NMoneys.Presentation.Resources.AllocatorView, Key=ColumnHeader_Number}" Binding="{Binding Number}" Width="60" CellStyle="{StaticResource NumberStyle}" />
我以前碰到的这个,看到一些技巧转发DC,但在这种情况下,它不是不值得麻烦。
干杯,
Berryl
'不工作'是非常具体的... – 2012-01-29 18:11:01
@ H.B。让我知道迭代#2是否更好地将问题带入焦点 – Berryl 2012-01-29 18:21:23
这是一个更多的信息,但是您不认为扩展有什么问题吗?如何发布其代码? – 2012-01-29 18:59:20