Reputation: 981
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
Upvotes: 0
Views: 482
Reputation: 981
I achieved my goal by writing
chkMaze.IsOn = TestMaze
on the SizeChanged event of the page. I didn't knew SizeChanged occurs before Loaded.
Upvotes: 1