开发者

"key cannot be null" when parsing xaml in a datagrid text column

I have a DataGrid and it has a text column in it, configured this way:

  <dg:DataGridTextColumn Header="{x:Static ResViewModel:SC.Resources.HelloWorld}" />

Here ResViewModel is the xmlns:namespace, SC is the project namespace, Resources is the resource file name and HelloWorld is a string property.

But I try to parse this xaml, I get an error like

Key cannot be null. Parameter name: key...

Can you he开发者_StackOverflow社区lp me to understand why is this error occuring? Also what is the best way to access resource file without using the LocBAML tool?


I see some issues:

  1. "SC is the project namespace" - that should go into the xmlns definition.
  2. You can't access files with this syntax, unless you have a dependency object with the same name.

There's a good approach to retrieving strings that is described here. It's focusing on Localisation, but it will work for a single language as well. This approach has it's downsides, but it's the lesser evil than other routes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜