Wpf 使用标签扩展为对象的属性赋值。

1,
使用标签扩展为对象的属性赋值。

如图:

 

 

代码如下:

Wpf 使用标签扩展为对象的属性赋值。 TextBlock
1    < Window.Resources >
2           < sys:String x:Key = " hellostring " > HelloString </ sys:String >
3          
4       </ Window.Resources >
5       < Grid >
6           < TextBlock Height = " 20 "  Width = " 300 "  Text = " {StaticResource ResourceKey=hellostring} " />
7       
8       </ Grid >

 

3,使用动态绑定扩展标签

  textbox的值随着滑块的滑动而改变。

如图:

 

 代码如下:

Wpf 使用标签扩展为对象的属性赋值。 Binding
1    < Grid >
2           < Grid.RowDefinitions >
3               < RowDefinition Height = " 33 " ></ RowDefinition >
4               < RowDefinition Height = " 4 " ></ RowDefinition >
5               < RowDefinition Height = " 30 " ></ RowDefinition >      
6           </ Grid.RowDefinitions >
7           < TextBox x:Name = " tb "  Text = " {Binding ElementName=sld, Path=Value} "   ></ TextBox >
8           < Slider x:Name = " sld "  Grid.Row = " 2 "  Value = " 50 "  Maximum = " 100 "  Minimum = " 0 " ></ Slider >
9       </ Grid >

 


 

参考:Wpf扩展标签

 

你可能感兴趣的:(WPF)