【发布时间】:2016-10-14 12:24:24
【问题描述】:
我有一个 WPF-MVVM 应用程序,并且我正在将按钮的内容与 ViewModel 绑定。 有时会发生新内容包含“()”内的文本。
<Button Grid.Row="0" Content="{Binding UnfinishedText}"
FontSize="22" Grid.Column="7"
Height="Auto" Foreground="White"
Style="{StaticResource MaterialDesignToolButton}"
Command="{Binding ShowUnfinishedProcedures}"
CommandParameter="{Binding ElementName=MainWindow}"/>
public string ToDoText
{
get { return _toDoText; }
set
{
_toDoText = value;
RaisePropertyChanged("ToDoText");
}
}
假设我绑定了新内容:“Hello(60)”。是否可以在此示例中仅为括号中的文本更改前景?
我计划使用Button.ContentChanged 事件但它不存在。
谁能帮帮我?
【问题讨论】: