Take the 2-minute tour ×

I have a variable in Universal.vb module in my Windows Store App (Windows 8/8.1).

Public TestMaze As Boolean = (GtSt("MazeOn", 0) = 1)

I want to use TestMaze in a XAML page to turn on/off a ToggleButton. The code looks like this:

<ToggleSwitch x:Name="chkMaze" IsOn={StaticResource TestMaze}"/>

What is the right method to do it?

PS: I do not want to do it on Loaded event of the page because it cause an impulse flicker in ToggleButton. PS2: GtSt is a function I defined for quicker access for RoamingSettings.

Public Function GtSt(SettingName As String, Optional DefaultVal As Double = 0) As Double
    Dim ProgSet = Windows.Storage.ApplicationData.Current.RoamingSettings
    If Not ProgSet.Values.ContainsKey(SettingName) Then
        SvSt(SettingName, DefaultVal)
    End If
    GtSt = ProgSet.Values(SettingName)
End Function
share|improve this question
The redundant department of redundancy called, they want their If(condition, True, False) back. Just write condition. –  Konrad Rudolph Jul 20 '13 at 18:34
Oops! hahaha. My bad. I don't appreciate redundancy neither. –  Ajay Raghav Jul 21 '13 at 16:03
add comment

1 Answer

up vote 1 down vote accepted

I achieved my goal by writing

chkMaze.IsOn = TestMaze

on the SizeChanged event of the page. I didn't knew SizeChanged occurs before Loaded.

share|improve this answer
add comment

Your Answer


