DependencyProperty data binding

Aug 5 2011 7:32 AM
Hello!

I try to bind my UI to custom DependencyProperty:

...

<window.resources>
  <local:localization x:key="Localization" ></local:localization>
</window.resources>
  <grid name="mainStack" datacontext="{StaticResource Localization}">
  <Button Padding="10,3" Margin="5" Content="{Binding Path=BtnAdd}"  Command="New"/>;
  </grid>




Also I have class "Localization":

class Localization : DependencyObject, INotifyPropertyChanged
  {
  public static DependencyProperty BtnAddProperty;
   
  static Localization()
  {
  BtnAddProperty = DependencyProperty.Register("BtnAdd", typeof(string), typeof(Localization));
   
  }

  public string BtnAdd
  {
  set
  {
  SetValue(BtnAddProperty, value);
  }
  get
  {
  return (string)GetValue(BtnAddProperty);
  }
  }

  public event PropertyChangedEventHandler PropertyChanged;

  protected virtual void OnPropertyChanged(string propertyName)
  {
  PropertyChangedEventHandler handler = this.PropertyChanged;
  if (handler != null)
  {
  PropertyChangedEventArgs e = new PropertyChangedEventArgs(propertyName);
  handler.Invoke(this, e);
  }
  }

  public Localization()
  {
  BtnAdd = MainWindowRes.BtnAdd;
  }

  public void SwitchLanguage()
  {
  BtnAdd = MainWindowRes.BtnAdd;
  OnPropertyChanged("BtnAdd");
  }
   
  }


First time my UI element gets my property value. But when I use my method SwitchLanguage(), property gets new data, and UI still have first value.

Can someone help me please?

P.S.
Sorry, for my English.

Yevgeniy