Assigning the Tag Property of a Control in WPF
If I have 7 checkBo开发者_运维百科xes, one for each day of the week, Can I assing in XAML the Tag property to each one of the the System.DayOfWeek enumeration value?
<StackPanel >
<StackPanel.Resources>
<system:DayOfWeek x:Key="Monday" >Monday</system:DayOfWeek>
</StackPanel.Resources>
<CheckBox Name="chkMo" Tag="{StaticResource Monday}">Mo</CheckBox>
...
</StackPanel>
Is there a way to assign directly the enum value to the tag without using resources?
Yes, try the following:
<CheckBox Name="chkMo" Tag="{x:Static system:DayOfWeek.Monday}">Mo</CheckBox>
精彩评论