9
比方說,我有一個類定義類似下面:常量在XAML
namespace MyProject.MyConstants
{
public class Constants
{
public class Group1Constants
{
public const string DoIt= "DoIt";
}
}
}
我試圖用這個常量,從一個單獨的項目,在我的XAML。我包括名字空間:
xmlns:constants="clr-namespace:MyProject.MyConstants;assembly=MyProject.MyConstants"
,我試圖按如下方式使用常量:
<MenuItem Header="{x:Static controls:Constants.Group1Constants.DoIt}">
以上不會編譯不過,他說,
Cannot find the type 'Constants.Group1Constants'. Note that type names are case sensitive.
我一定是簡單的東西。我想要做的就是使用xaml中不同項目中的類中的一些常量。
有什麼建議嗎?
太棒了,修正了它!我從來沒有見過「+」語法。 – Flack 2010-10-14 02:43:12
wtf是「+」語法嗎? – wil 2013-11-14 02:30:10
謝謝,WPF讓我驚歎於它的語法 – Viju 2017-11-10 15:26:53