xaml - In WPF, how do I set a button's click event to change a grid's visibility? -
i'm trying set button's event change grid's visibility using xaml. i'm pretty sure should using eventtrigger, couldn't work recent attempt create datatrigger bound field in view-model:
<style x:key="personalinfogridstyle" targettype="{x:type grid}"> <style.triggers> <datatrigger binding="{binding path=personalinfogridvisibility}" value="collapsed"> <setter property="grid.visibility" value="collapsed"/> </datatrigger> </style.triggers> </style>
the above code isn't working, matters less me achieving whole thing in xaml (without using view-model or code-behind).
can explain how should go or if it's possible? :) ahead
can use toggle button?
<window x:class="wpfapplication1.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="mainwindow" height="350" width="525"> <grid> <grid.resources> <booleantovisibilityconverter x:key="boolconverter" /> </grid.resources> <grid.rowdefinitions> <rowdefinition height="auto" /> <rowdefinition height="*" /> </grid.rowdefinitions> <togglebutton content="click me" x:name="toggleme" grid.row="0" /> <grid grid.row="1" background="black" visibility="{binding elementname=toggleme, path=ischecked, converter={staticresource boolconverter}}"> </grid> </grid> </window>
Comments
Post a Comment