在Expression Blend 4(Silverlight項目)中我有一個UserControl,我已添加了一個CLR屬性。該屬性是在UC內定義的枚舉類型。我已將ChangePropertyAction行爲附加到UC的一個實例。然而,XAML分析器提供了以下錯誤(等等):引用XAML中的類中定義的枚舉
「+」是不是在
這是因爲下面的XAML(片斷)已經生成一個名稱有效:
<local:SomeControl Margin="155,113,317,0" d:LayoutOverrides="Width, Height">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonDown">
<ei:ChangePropertyAction PropertyName="MyProp">
<ei:ChangePropertyAction.Value>
<local:SomeControl+MyEnum>Second</local:SomeControl+MyEnum> <----- Error on this line caused by the '+'
</ei:ChangePropertyAction.Value>
</ei:ChangePropertyAction>
</i:EventTrigger>
</i:Interaction.Triggers>
</local:SomeControl>
背後的代碼:
public partial class SomeControl : UserControl
{
public SomeControl()
{
// Required to initialize variables
InitializeComponent();
}
public MyEnum MyProp
{
get; set;
}
public enum MyEnum
{
First,
Second,
Third
}
}
一個簡單workround是 「促進」 噸他從類內部枚舉(例如SomeControl_MyEnum),但有沒有更清晰的解決方案?
感謝您的回覆。然而事實證明,x:Static只是WPF,我沒有提到我的項目是Silverlight。對不起,我很愚蠢。 – SoundCrowd 2010-10-10 21:49:17
經過一些試驗和錯誤後,我發現我可以簡單地替換ChildPropertyAction.Value元素,並將所需的枚舉值作爲父元素的Value屬性插入。當然,每當我改變Blend中的ChangePropertyAction行爲時,我都必須重新編輯並再次編輯。 – SoundCrowd 2010-10-10 21:53:15
啊,我看到我**在標籤中提到了Silverlight,但不是主體。已更新帖子以澄清。 – SoundCrowd 2010-10-10 21:57:45