开发者

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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜