settings page using toggle

2 posts, 0 answers
  1. brandon
    brandon avatar
    12 posts
    Member since:
    May 2014

    Posted 09 May 2014 Link to this post

    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);
              //}
           }
  2. Todor
    Admin
    Todor avatar
    778 posts

    Posted 14 May 2014 Link to this post

    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.

     
  3. DevCraft banner
Back to Top