This is a migrated thread and some comments may be shown as answers.

settings page using toggle

1 Answer 56 Views
ToggleSwitch
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
brandon
Top achievements
Rank 1
brandon asked on 09 May 2014, 06:25 PM
I'm making a settings page where i want to change the tranparency of my hubtile from on to off. i have the IsTranparencySupported set up like this

IsTransparencySupported = settings.TransparencySettings._Transparency,

the _Transparency var is set up like this (hope this is right)
public class TransparencySettings
       {
 
           public const bool _Transparency = true;
 
       }

if i manually change the value from true to false it works. but i want to use the toggle to set it. so i have the toggle set up with the 2 options checked and unchecked. see below

my toggle xaml looks like this
<telerikPrimitives:RadToggleSwitch x:Name="ToggleTransparent" IsChecked="True" HorizontalAlignment="Left" Margin="262,73,0,0"
                                            VerticalAlignment="Top"
                                            Content="On"
                                            Unchecked="ToggleUnchecked"
                                            Checked="ToggleChecked"/>

i can't figure out how to set the _Transparency variable in code...can you help
this is what i have...it's commented out because i'm testing different options.

public void ToggleUnchecked(object sender, RoutedEventArgs e)
       {
 
           //ToggleTransparent.IsChecked = false;
            
          //if (TransparencySettings._Transparency== true)
          //{
          //    TransparencySettings._Transparency == TransparencySettings._Transparency(false);
          //}
       }

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 14 May 2014, 01:47 PM
Hello Brandon,

Thank you for your question.

You have declared the _Transparency as a constant. Constants are used only when the value of a variable will not be changed. After you remove the const declaration you can set the value to true in the event handler for the Checked event and to false - on Unchecked. You can also use the CheckedChanged event instead since it is fired both times:

private void RadToggleSwitch_CheckedChanged(object sender, Telerik.Windows.Controls.CheckedChangedEventArgs e)
{
    TransparencySettings._Transparency = e.NewState;
}

I hope this information helps.

Regards,
Todor
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
ToggleSwitch
Asked by
brandon
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or