xaml - Select a different grid based on a converter's value for a UWP app -


in uwp app, have property returns 3 values. want show different grid based on value using converter. best way achieve this? direction think going head towards create 3 different grid templates, , set style 1 of these 3 templates based on converter returns. know if work? grid doesn have grid, can contentcontrol or that. want show different section of ui based on property

thanks

i use windowsstatetriggers nuget package.

once installed can reference @ top of xaml

xmlns:triggers="using:windowsstatetriggers" 

and had property in backend class called isbusy

public bool isbusy { get; set; } = false; 

and example had 2 simple grids in xaml.

<stackpanel x:name="root">     <grid x:name="redgrid" background="red" width="200" height="100" />     <grid x:name="greengrid" background="green" width="200" height="100" visibility="collapsed"/> </stackpanel> 

you setup visual state group show grids based on isbusy property. want green grid visible , red grid collapsed when isbusy = true

 <stackpanel x:name="root">      <visualstatemanager.visualstategroups>          <visualstategroup>              <visualstate x:name="isbusy">                  <visualstate.statetriggers>                      <triggers:equalsstatetrigger equalto="true" value="{binding isbusy, elementname=root}" />                  </visualstate.statetriggers>                  <visualstate.setters>                      <setter target="redgrid.visibilty" value="collapsed"/>                      <setter target="greengrid.visibility" value="visible" />                  </visualstate.setters>              </visualstate>          </visualstategroup>      </visualstatemanager.visualstategroups>      <grid x:name="redgrid" background="red" width="200" height="100" />      <grid x:name="greengrid" background="green" width="200" height="100" />  </stackpanel> 

nb {binding isbusy, elementname=root} depends on datacontext , location of isbusy property. here in code behind page. hope gives idea.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -