0

In my UWP application, I have a SplitView which contains different pages as frames. This works without any Problem. Now I need to update some content of the SplitViewPane. For an example, I have a RadioButton in my SplitView, which is called Home. Behind this text, I have an Ellipse with a TextBlock for indicating notifications. So I need a way to update this TextBlock from other pages or classes. I have implemented a class with the INotifyPropertyChanged Event and set the binding to this TextBlock, but I Need to set the Content somewhere.

/Edit 1

This is my Class:

public class Notification : INotifyPropertyChanged
{
    private int _notification;
    public int notification
    {
        get
        {
            return _notification;
        }
        set
        {
            _notification = value;
            RaisePropertyChanged();
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;
    protected void RaisePropertyChanged([CallerMemberName] string name = "")
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(name));
        }
    }
}
andy
  • 509
  • 1
  • 8
  • 21
  • Can you show your class and code responsible for binding? – Romasz Jun 05 '16 at 05:46
  • I have added my class to my question, but i dont really know how to go further. – andy Jun 05 '16 at 06:03
  • How have you declared the binding of your TextBlock? Where you use that class? Have you thought about declaring *Notification* variable in App class and then access it from your pages/classes? – Romasz Jun 05 '16 at 06:17
  • In my TextBlock i have added the binding to the text property: Text="{Binding notification}" But i dont know how to set the ItemsSource or DataContext from such a class, to make the binding work. You mean in app.xaml.cs ? Is this the best way to do this? – andy Jun 05 '16 at 07:17
  • There are couple of ways to set the DataContext, generally if it's not set it takes parent's one. You can also set it explicitly in code `textBlock.DataContext = your class;`, you can also bind in xaml to another property and this property should point to your notification class. – Romasz Jun 05 '16 at 07:49

0 Answers0