I have got a base XAML page which is the basis for a navigation layout, with buttons on the top opening various views in the middle. This is done using a navigation Frame and UriMapper.
I’ve placed a few controls (DatePickers to be exact) on the navigation panel, as they will be needed by the views to filter out data.
However, I don’t know how to apply any kind of data binding to the subsequent views, which are, after all, separate XAML files.
I need to be able to read the values from the DataPickers and, ideally, react to the values being changed by the user.
How should I go about doing this?
Here is what I would be inclined to do.
Create a
CriteriaServiceclass using this pattern:-Now add an instance of this service to App.Xaml.cs:-
In your main page your do something like this:-
so that you can use simple bindings like
SelectedDate="{Binding StartDate}"in your criteria controls.Now in your various pages you have a choice. In code you can access the
CriteriaServiceas:-Or if you want to bind to values from it in your page xaml you can use something like:-