如何从WPF中的类触发xaml代码?
它工作得很好:如何从WPF中的类触发xaml代码?,xaml,Xaml,它工作得很好: <Button Width="100" Height="30" Content="Click Me!"> <Button.ToolTip> <Border Margin="-4,0,-4,-3" Padding="10" Background="Silver"> <Border.BitmapEffect> <OuterGlowBit
<Button Width="100" Height="30" Content="Click Me!">
<Button.ToolTip>
<Border Margin="-4,0,-4,-3" Padding="10" Background="Silver">
<Border.BitmapEffect>
<OuterGlowBitmapEffect></OuterGlowBitmapEffect>
</Border.BitmapEffect>
<Label>Nice tooltip</Label>
</Border>
</Button.ToolTip>
</Button>
很好的工具提示
但是,我希望在有条件时撤销代码。例如:
if(str=="aaa")
MessageBox.Show("All will be o'kay");
else
{
//I would like this code to revoke
/* <Border.BitmapEffect>
<OuterGlowBitmapEffect></OuterGlowBitmapEffect>
</Border.BitmapEffect>
*/
}
if(str==“aaa”)
MessageBox.Show(“一切都将是奥凯”);
其他的
{
//我想撤销这个代码
/*
*/
}
如何操作?只需创建一个引发通知的属性。您可以实现INotifyPropertyChanged接口。更改代码中属性的值并用xaml绑定它