1
Answer

How to manage the toggle button click events, backgrounds

Photo of sravankumar J

sravankumar J

8y
449
1
Hi, I have started developing a simple UWP application and I'm new to XAML  and UWP.
I have two grids in my mainpage.xaml and two toggle buttons(named g1, g2) on top of the page, by default they both have false for the IsChecked attribute.
When I click on g1 it should highlight and shows the grid1 on the screen vise versa when I click on g2 it should highlight, displays the grid2 and hides the grid1.
Could you please tell me how to do this in xaml.
Any answers appreciated.
 
Thank you. 

Answers (1)

1
Photo of Suresh M
NA 18.6k 1.5m 8y
<ToggleButton Height="100" Width="200" IsChecked="False" Checked="ToggleButton_Checked" Unchecked="ToggleButton_Unchecked" ></ToggleButton>
Hi just set the visibility of the grid visible and Collapsed(by default set Collapsed)
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Visibility="Collapsed">
when you checked the toggle button set your g1 grid visibility to visible and g2 hide it vice versa
Accepted