WPF MultiBinding 实现控件 Tooltip 多绑定
来源:互联网 发布:知乎日耳曼和凯尔特 编辑:程序博客网 时间:2024/05/18 03:52
//convert
public class CanBeAppliedDisplayConverter : IMultiValueConverter
{#region Implementation of IMultiValueConverter
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values[0].ToString() == string.Empty || values[1].ToString() == string.Empty)
return "";
return values[0].ToString() + values[1].ToString();
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
//viewmodel
public class viewmodel : INotifyPropertyChanged
{
private string _name1;
public string name1
{
get { return _name1; }
set
{
_name1 = value;
OnPropertyChanged("name1");
}
}
private string _name2;
public string name2
{
get { return _name2; }
set
{
_name2 = value;
OnPropertyChanged("name2");
}
}
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}
//xaml
<TextBlock DataContext="{Binding}">
<TextBlock.ToolTip>
<ToolTip >
<TextBlock DataContext="{Binding}">
<TextBlock.Text>
<MultiBinding Converter="{StaticResource CanBeAppliedDisplayConverter}">
<Binding Path="name1" />
<Binding Path="name2" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</ToolTip>
</TextBlock.ToolTip>
</TextBlock>
- WPF MultiBinding 实现控件 Tooltip 多绑定
- WPF之Binding基础十一 MultiBinding多路绑定
- WPF-004 控件 ToolTip
- WPF ToolTip控件使用
- wpf中的 绑定Binding MultiBinding StringFormat格式转化问题
- WPF中的MultiBinding
- 数据绑定(十一)多路绑定MultiBinding
- WPF ToolTip绑定到依赖属性
- WPF MultiBinding 给数据目标赋值后绑定无效的问题
- WPF应用Binding之MultiBinding
- WPF 实现数据结构对象与UI控件的绑定
- WPF 参照WPF实现Silverlight中的多值绑定特性
- WPF 控件中的数据绑定
- WPF数据绑定(1) 绑定到控件
- WPF(MultiBinding 数据对比验证,启用提交)
- WPF Get Multibinding Expression, Update Source,
- WPF新手之控件多对一的绑定
- WPF控件与控件值的绑定
- Maya: 菜单 编辑曲线 > 复制曲面曲线
- Hibernate的Session
- hadoop开发:cenos网络配置
- SPOJ AMR12I Saruman of Many Colours 解题报告
- Maya: 菜单 编辑曲线 > 附加曲线
- WPF MultiBinding 实现控件 Tooltip 多绑定
- C++初步之三 小项目
- Maya: 菜单 编辑曲线 > 分离曲线
- uva 208 Firetruck (DFS + 并查集)
- ios与服务端的交互
- 使用dex2jar来反编译android代码
- [iOS]shell 自动打包工程
- Maya: 菜单 编辑曲线 > 对齐曲线
- 黑马程序员:毕向东java视频之面向对象篇一(三大特性)