2017-04-25 71 views
0

到目前爲止,xlmns:x對我來說似乎並不重要,但現在我喜歡用一個類型爲「x:String」的數組創建ResourceDictionary。 默認xlmns:x命名空間引用版本2006,但不支持字符串。自2009年以來,它是supported。所以我喜歡使用更新的版本。 要完成這一步,哪些步驟是必需的?如何更改Microsoft架構版本

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2009/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
        xmlns:local="clr-namespace:HMBFipsReminderUI"> 
    <x:Array x:Key="DataGrid_SampleItemSource" Type="x:String"> 

    </x:Array> 
</ResourceDictionary> 

重命名沒有幫助,因爲visual studio找不到命名空間。 1.是否有添加此命名空間的選項?

  1. 如何更改默認版本?所以,當我創建一個新的資源,頁等

回答

1

String新的命名空間將被用於在System命名空間中的mscorlib組件的類型:

xmlns:s="clr-namespace:System;assembly=mscorlib" 

試試這個:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
          xmlns:local="clr-namespace:HMBFipsReminderUI" 
          xmlns:s="clr-namespace:System;assembly=mscorlib"> 
    <x:Array x:Key="DataGrid_SampleItemSource" Type="{x:Type s:String}"> 
     <s:String>a</s:String> 
     <s:String>b</s:String> 
     <s:String>c</s:String> 
    </x:Array> 
</ResourceDictionary>