2013-01-16 29 views
4

元我想定義的double值,這樣我可以在許多UIElements我如何定義StandardStyles.xaml

<Double x:Key="MyWidth">100</Double> 
<String x:Key="MyString">This is my text</String> 

它給我的錯誤Double is not supported in a Windows App project.和同樣是字符串重用。

如果我在StandardStyles.xaml中包含xmlns:sys="using:System"那麼它正在編譯。

<sys:Double x:Key="MyWidth">100</sys:Double> 
<sys:String x:Key="MyString">This is my text</sys:String> 

它在運行時XAML Parsing Failed. The type 'Double' was not found.

回答

6

給予例外有沒有需要包括System命名空間。
已經有一個命名空間包含xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

<x:Double x:Key="MyWidth">100</x:Double> 
<x:String x:Key="MyString">This is my text</x:String> 
+0

出於某種原因,這是行不通的。我收到錯誤「Windows Presentation Foundation(WPF)項目不支持Double。」我在.NET 4.0上。 – Pompair

+0

Pompair不能說你爲什麼面臨這個問題,自去年以來我還沒有贏取代碼 –