1.附加属性(Attached Properties)
控件放到布局里之后,会附加布局的属性
作用就是将属性与数据类型(宿主)解耦
让数据类型的设计更加合理
2.if(!“true”.Equals(JsonConfigHelper.getConfig(“showTestButton”)))
显示测试按钮
TimeSpan(int days,int hours,int minutes,int seconds,int millisecond);
天时分秒毫秒
时分秒毫秒
时分秒
3.各种组件及其成员
4.binding的用法
Simple Binding.xaml
<Window...
Title = "Simple Binding">
<StackPanel>
<TextBox x:Name="TextBoxName" BorderBrush="Black" Margin="5"/>
<Button Content="Add Age" Margin="5" Click="Button_Click"/>
</StackPanel>
</Window>
Simple Binding.cs
public partial class Window1:Window
{
Student stu;
public Window1()
{
InitialzeComponent();
//准备数据源
stu = new Student();
//准备Binding
Binding bingding = new Binding();
binding.Source = stu;
binding.Path = new PropertyPath("Name");
//使用Binding连接数据源与Binding目标
BindingOperations.SetBinding(this.textBoxName,TextBox.TextProperty,binding);
}
private void Button_Click(object sender,RoutedEventArgs e)
{
stu.Name += "Name";
}
}
以上步骤可以三合一
public Window1()
{
InitialzeComponent();
//三合一操作
this.textBoxName.SetBinding(TextBox.TextProperty,new Binding("Name"))
{
}
}
5.x:code可以在标签内写入C#代码
使用style标签来指定所有Button的样式
<Window.Resources>
<style x:key = "{x:Type Button}" TargetType = "{x:Type Button}"/>
<setter Property = "width" Value = "60"/>
<setter Property = "height" Value = "70"/>
<setter Property = "color" Value = "black"/>
</style>
</Window.Resources>
<StackPanel>
<Button Content = "123"/>
<Button Content = "1234" style = "{x:Null}"/>
</StackPanel>