开发者

App : Application,INotifyPropertyChanged doesn't raise NotifyPropertyChanged

class App : Application,INotifyPropertyChanged doesn't raise NotifyPropertyChanged.

I want update fill property from other class (path in App.xaml in style) .I want to do it from other class.Like this: App.xaml.cs

public bool isShuffle {
    get {
      return _isShufle;
    }
    set {
        _isShufle = value;
        OnPropertyChanged(new PropertyChangedEventArgs("isShuffle"));
    }
}

App.xaml:

<Path Height="59"
      Data="M15.999,4.308开发者_如何学运维0001 C17.228001,4.309 18.402,4.5219998 19.514,4.8779998 L18.6"
      Fill="{Binding isShuffle ,
                     Converter={StaticResource AudioColor}}"
      />

But nothing updates.


public bool isShuffle {
      get {
        return _isShufle;
      }
      set {
        if (_isShufle != value){
         _isShufle = value;
        OnPropertyChanged("isShuffle");

} } }

// Create the RaisePropertyChanged method to raise the event
    protected void OnPropertyChanged(string name)
    {
        PropertyChangedEventHandler handler = PropertyChanged;
        if (handler != null)
        {
            handler(this, new PropertyChangedEventArgs(name));
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;

Also, you need to make sure you're setting the Context for the binding. For example, you can use ElementName if you're not setting the DataContext already.

`<Application 
    x:Class="MyApp.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/p...
    x:Name="control" ...`

And your binding itself

<Path Height="59"
                            Data="M15.999,4.3080001 C17.228001,4.309 18.402,4.5219998 19.514,4.8779998 L18.6"
                            Fill="{Binding Path=IsShuffle, ElementName=control, Converter={StaticResource AudioColor}}"
                            />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜