扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:轩辕南宫 来源:天极开发 2007年11月3日
关键字:
37 int a = 1; 38 int b; 39 b = a; |
01 <Binding ElementName[元素名]=" …" Path[属性名]="…"/> |
01 <Window 02 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 03 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 04 x:Class="SDKSample.Window1" 05 Width="460" 06 Height="200" 07 Title="BindDPtoDP"> 08 09 <DockPanel Background="White"> 10 11 <Button Click="btnChangeSource" Width="150" Height="30" 12 DockPanel.Dock="Top">Change Source Property</Button> 13 14 <TextBlock Name="Text1" DockPanel.Dock="Top" FontSize="12" 15 Height="30" Foreground="Green"> 16 <TextBlock.Text> 17 Click the Button to Change this Initial Text Value in this Source Element 18 </TextBlock.Text> 19 </TextBlock> 20 21 <TextBox DockPanel.Dock="Top" Height="30" Foreground="Blue"> 22 <TextBox.Text> 23 <Binding ElementName="Text1" Path="Text"/> 24 </TextBox.Text> 25 </TextBox> 26 27 </DockPanel> 28 29 </Window> |
01 using System; 02 using System.ComponentModel; 03 using System.Windows; 04 using System.Windows.Controls; 05 using System.Windows.Documents; 06 using System.Windows.Data; 07 using System.Windows.Media; 08 09 namespace SDKSample 10 { 11 /// <summary> 12 /// Window1: This is the class that encapsulates the code 13 /// "behind" the Window1.Xaml page. 14 /// </summary> 15 public partial class Window1 : Window 16 { 17 static int iCount = 0; 18 19 void btnChangeSource(object sender, RoutedEventArgs e) 20 { 21 iCount++; 22 Text1.Text = string.Format("New Text. Count={0}", iCount); 23 } 24 } 25 } |
![]() |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。