绑定数据、数据自定义转换
自定义事件转:Binding值转换器ValueConverter使用
public class WrapConver : IValueConverter
设定为资源
<Window.Resources> <local:WrapConver x:Key="cvwDate" /> </Window.Resources>
绑定使用
TextWrapping="{Binding IsChecked, Converter={StaticResource cvwDate}, ElementName=chenkbox自动分行}"TextBox多行文本的设置
TextWrapping=“Wrap”//自动换行 AcceptsReturn=“True”//接受回车
绑定数据: 在表单区需要上下文来关联,在编辑区如下: 设定数据
public class 字幕时码 : INotifyPropertyChanged
{
private string cy字幕;
public event PropertyChangedEventHandler PropertyChanged;
public string 字幕
{
get { return cy字幕; }
set
{
cy字幕 = value;
//激发事件
if (this.PropertyChanged != null)
{
this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs("字幕"));
}
}
}
}
绑定数据
//绑定数据
字幕时码 Cy字幕时码 = new 字幕时码();
//准备Binding
Binding binding = new Binding();
binding.Source = Cy字幕时码;
binding.Path = new PropertyPath("字幕");
BindingOperations.SetBinding(this.TextBox文本编辑区,TextBox.TextProperty, binding);
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。