I am new to XAML and C #, but I enjoyed working after a couple of weeks when I played with it. I started working on the application and put together a simple "Settings" page in XAML; Now I am trying to connect events to the controls in order to (a) update the state of the application when the user interacts with them, and (b) have the current state when visiting the page.
I hit two (connected) road blocks, though:
Toolkit: The ListPicker control does not work when I define "ListPickerItem" in XAML, so in the SettingsPage constructor I set the contents manually:
lpColour.ItemsSource = new List<string>()
{
"Red","Blue","Green","Custom…"
};
lpColour.SelectedIndex = 1;
However, since the control (lpColour in this example) has an event on SelectionChanged, two events are fired (one with "red" selected when the window is filled, and then the other when "Blue" is selected). I do not want to handle "SelectionChanged" at the moment; only when the user interacts with the control itself (for example, if they select "Custom ...", I can open a separate text block and give it focus, but I do not want to do this when I configure and they have selected "Custom ... "because otherwise the user will receive the keyboard as soon as they open the settings page ...)
- , , ToggleSwitch "" "", "IsChecked" - . , ? ( , "", , ).
, , - "" (, "" " " ) "SelectionChangedEventArgs" "RoutedEventArgs"... , , ?
"" bool ( "false" , "true" Constructor "if (initialized) {...}", , "lpColour.ItemSource =..." "lpColour.SelectedIndex = 1", , "initialized" "false". .: P
, - !
, . !
- @MyKuLLSKI, .
, , " " IgnoreSelectionChanged " int, " "( ListPicker ItemSource " IgnoreSelectionChanged + = 2 "( , ), , " IgnoreSelectionChanged ++ " SelectedIndex ..., .
"ObservableCollection", ListPicker , , , , "SelectionChanged" ListPicker, .
!