ContentPropertyAttribute 类

指定在通过 XAML 处理器分析某个类时,可以将该类的哪个属性解释为内容属性。(XAML子元素隐式添加到的属性)

A </local:User>

(该子元素将添加到其Name属性中)

)] public class User { public string UserName { get; set; } public string UserCode { get; set; } public string Email { get; set; } }

1 内容控件

只包含单一项的控件,其Content属性的类型为object

如果其内容为UIElement或者模板,则对其进行渲染,否则调用ToString()方法,将返回值放到TextBlock里

 

  • 以编程方式点击一个按钮
void Do() { //模拟按钮点击 ButtonAutomationPeer bap = new ButtonAutomationPeer(Button1); IInvokeProvider iip = bap.GetPattern(PatternInterface.Invoke) as IInvokeProvider; iip.Invoke(); }
  • CheckBox与RadioButton都继承自ToggleButton,其IsChecked属性是一个Nullable<Boolean>的值
  • 当RadioButton没有显示设置GroupName时,其互斥性是基于所在的组,下面代码将前4个与后2个RadioButton分为了两组
RadioButton Content="RadioButton" Name="radioButton" GroupName="A"/> <RadioButton Content="RadioButton" Height="16" Name="radioButton1" GroupName="A"/> <RadioButton Content="RadioButton" Height="16" Name="radioButton2" GroupName="A"/> </StackPanel> <StackPanel Height="88" HorizontalAlignment="Left" Margin="8,200,0,0" VerticalAlignment="Top" Width="200"> <RadioButton Content="RadioButton" Height="16" Name="radioButton3" GroupName="A"/> <RadioButton Content="RadioButton" Height="16" Name="radioButton4" /> <RadioButton Content="RadioButton" Height="16" Name="radioButton5" /> </StackPanel>

2 Item控件

ItemsControl 把它的内容包含在Items属性中

DisplayMemberPath可以指定其每一项的属性的名字

相关文章:

  • 2021-07-10
  • 2022-12-23
  • 2021-07-20
  • 2021-06-11
  • 2021-12-09
  • 2022-02-01
  • 2022-12-23
  • 2021-09-10
猜你喜欢
  • 2021-05-31
  • 2021-06-27
  • 2022-01-25
  • 2021-12-04
  • 2021-09-25
相关资源
相似解决方案