<Window x:Class="SRQC_DataTrigger_Property.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TextBox x:Name="txt1" />
<TextBox x:Name="txt2" />
<TextBox x:Name="txt3" Text="{Binding MyMessage}" />
</Grid>
</Window>
using System.ComponentModel;
using System.Windows;
namespace SRQC_DataTrigger_Property
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.DataContext = new MainWindowViewModel();
}
class MainWindowViewModel : NotificationObject
{
private string myMessage;
/// <summary>
/// ??
/// </summary>
public string MyMessage
{
get { return myMessage; }
set
{
myMessage = value;
this.RaisePropertyChanged("MyMessage");
}
}
}
class NotificationObject : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void RaisePropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)
{
this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}
} 在XAML中写触发器,如何写当txt1.Text="ABC"和txt2.Text="123"的时候,设置MyMessage="Changed";谢谢
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货