2012-11-17 30 views
0

它工作正常:如何在WPF中從類中觸發xaml代碼?

<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> 
     */ 
    } 

怎麼辦?

回答

1

只需創建一個引發通知的屬性即可。你可以實現INotifyPropertyChanged接口。更改代碼中的屬性值並將其與xaml綁定。

+0

好的。我將閱讀有關INotifyPropertyChanged接口。 – StepUp