110,561
社区成员
发帖
与我相关
我的任务
分享
<Window x:Class="WPF2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WPF2"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<local:ContentConvert x:Key="aa"/>
</Window.Resources>
<Grid Name="grid1">
<Button Name="button1" Content="萧蔷" Height="30" Width="60"/>
<Button Name="button2" Content="{Binding ElementName=button1, Path=Content, Converter={StaticResource aa}}"/>
</Grid>
</Window>
class ContentConvert : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string content = value as string;
if (content == null)
return null;
return "我不喜欢" + content;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}