xaml - C# - UWP: Load different view in one base views -
i software developer student , schoolproject searching solution loading different views in baseview. got uwp application, runs on raspberry pi.
application need te navigatie between 2 users (regular- , expert user).
so question?
how switch between 2 users, without reload views(pages)?
views cannot refresh because content real-time , has run when switch between user views.
it c# uwp application. have files:
- baseview.xaml (this (main)view want load aview or bview)
- aview.xaml
- bview.xaml
maby can me it?
thanks.
you can place contentpresenter baseview. wrap aview , bview data templates. can use converter select template contentpresenter shows.
<page> <page.resources> <datatemplate x:key="aviewtemplate"> <views:aview /> </datatemplate> <datatemplate x:key="bviewtemplate"> <views:bview /> </datatemplate> <conv:modetotemplateconverter atemplate="{staticresource aviewtemplate}" btemplate="{staticresource bviewtemplate}" /> </page.resources> <contentpresenter content="{binding yourviewmodel}" contenttemplate="{binding mode, converter={staticresource modetotemplateconverter}}" /> </page>
the converter can that:
public class modetotemplateconverter : ivalueconverter { public datatemplate atemplate { get; set; } public datatemplate btemplate { get; set; } public object convert(object value, type targettype, object parameter, cultureinfo culture) { var mode = value mode?; switch (mode) { case mode.a: return atemplate; case mode.b: return btemplate; default: return null; } } public object convertback(object value, type targettype, object parameter, cultureinfo culture) { throw new notimplementedexception(); } }
Comments
Post a Comment