I have a little question. I am trying to create a UWP C # application and I am using toggle switches in a project. If I switch ToggleSwitch status from software very often, memory usage is greatly increased. Why is this happening?
ToggleSwitch is a boolean using binding.
I created an example code:
XAML:
<Page x:Class="App1.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:App1" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <ToggleSwitch Header="Test" HorizontalAlignment="Left" Margin="213,27,0,0" VerticalAlignment="Top" IsOn="{Binding Path=TestBool, Mode=TwoWay}"/> <CheckBox Content="Two-state CheckBox" Margin="108,162,0,806" IsChecked="{Binding Path=TestBool, Mode=TwoWay}"/> <Button Content="Start!" HorizontalAlignment="Left" Margin="69,58,0,0" VerticalAlignment="Top" Click="Button_Click"/> </Grid>
WITH#:
using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using System.ComponentModel; using System.Runtime.CompilerServices;
Am I doing something that is impossible, that I misunderstand?
When I replace ToggleSwitch with CheckBox, the memory usage is much less.

source share