2014-02-12 50 views
2

我在我的班級像WPF 4.5結合靜態屬性

public partial class ShellWindow 
      { 
      private static Visibility progressbarVisibility = Visibility.Collapsed; 
      public static Visibility ProgressbarVisibility 
      { 
       get { return progressbarVisibility; } 
       set 
       { 
       if (progressbarVisibility == value) return; 
       progressbarVisibility = value; 
       RaiseStaticPropertyChanged("ProgressbarVisibility"); 
       } 
      } 
      public static event EventHandler<PropertyChangedEventArgs> StaticPropertyChanged; 
      public static void RaiseStaticPropertyChanged(string propName) 
      { 
      EventHandler<PropertyChangedEventArgs> handler = StaticPropertyChanged; 
      if (handler != null) 
      handler(null, new PropertyChangedEventArgs(propName)); 
    } 
    } 

我創造背後的代碼控制的靜態屬性,想用這個屬性綁定。 目前我這樣做

var binding = new Binding("ShellWindow.ProgressbarVisibility") { Mode = BindingMode.TwoWay }; 
    binding.Source = this; 
    progressbar = new CircularProgressBar(); 
    progressbar.SetBinding(VisibilityProperty, 
          binding); 

此綁定不起作用。 我正在努力遵循這article但我沒有得到我在做錯的地方。

+0

這個帖子看看,我認爲這將有助於:http://stackoverflow.com/questions/936304/binding-to-static-property – TrueEddie

回答