这是我的代码
[Flags]
public enum DeliveryDays
{
[Description("None")]
NONE = 0, // 0000000
[Description("monday")]
MON = 1, // 0000001
[Description("tuersady")]
TUE = 2, // 0000010
[Description("wedsnay")]
WED = 4, // 0000100
[Description("thursday")]
THU = 8, // 0001000
[Description("friday")]
FRI = 16, // 0010000
[Description("saturday")]
SAT = 32, // 0100000
[Description("sunday")]
SUN = 64, // 1000000
WORKDAYS = MON | TUE | WED | THU | FRI, //0011111
WEEKENDS = SAT | SUN //1100000
}
public class Finder
{
public DeliveryDays AvailableDays = DeliveryDays.WEEKENDS;
public DeliveryDays SelectedDays { get; set; }
public Finder()
{
SelectedDays = DeliveryDays.NONE;
}
}
这是 XAML
<ComboBox Height="50"
ItemsSource="{Binding Source={my:Enumeration {x:Type my:DeliveryDays}}}"
DisplayMemberPath="Description"
SelectedValue="{Binding SelectedDays}"
SelectedValuePath="Value" />
现在组合框向我显示所有枚举DeliveryDays
类型,但我只想要AvailableDays
实例成员字段中的枚举值。所以我需要修改自定义MarkupExtension
以仅在我的AvailableDays
字段中显示枚举值。如何从我的自定义EnumListExtension
方法访问此字段?如果在 XAML 中不可能,你有什么解决方法吗?
谢谢