private ListPicker CreateThemeColorListPicker()
 {
     ListPicker p = new ListPicker();
     p.Header = "Select document editor background color";
     p.Margin = new Thickness(12, 35, 12, 30);
     p.Items.Add(ThemeColor.dark);
     p.Items.Add(ThemeColor.light);
     p.Items.Add(ThemeColor.phone);
     p.SetBinding(ListPicker.SelectedItemProperty, GetBinding("NoteEditorThemeColor"));
     return p;
 }
Example #2
0
        private StackPanel RenderEditTaskListPointer(PropertyInfo pi, double minWidth)
        {
            StackPanel innerPanel;
            innerPanel = new StackPanel() { Orientation = System.Windows.Controls.Orientation.Horizontal };
            CheckBox listcb = new CheckBox() { DataContext = taskCopy, IsTabStop = true };
            listcb.SetBinding(CheckBox.IsCheckedProperty, new Binding("LinkedTaskListIDBool"));
            listcb.TabIndex = tabIndex++;
            ListPicker listPicker = new ListPicker()
            {
                MinWidth = minWidth,
                FullModeItemTemplate = (DataTemplate)App.Current.Resources["FullListPickerTemplate"],
                DataContext = listcb
            };
            listPicker.SetBinding(ListPicker.IsEnabledProperty, new Binding("IsChecked"));
            listPicker.ItemsSource = App.ViewModel.TaskLists;
            listPicker.DisplayMemberPath = "Name";
            Guid? taskListID = (Guid?)pi.GetValue(taskCopy, null);
            if (taskListID != null)
            {
                try
                {
                    TaskList taskListVal = App.ViewModel.TaskLists.Single(t => t.ID == (Guid)taskListID);
                    if (taskListVal != null)
                        listPicker.SelectedIndex = App.ViewModel.TaskLists.IndexOf(taskListVal);
                }
                catch (Exception)
                {
                    listPicker.SelectedIndex = 0;
                }
            }
            else
                listPicker.SelectedIndex = 0;

            // set the event handlers for the checkbox and listpicker
            listcb.Unchecked += new RoutedEventHandler(delegate { pi.SetValue(taskCopy, null, null); });
            listcb.Checked += new RoutedEventHandler(delegate { pi.SetValue(taskCopy, App.ViewModel.TaskLists[listPicker.SelectedIndex].ID, null); });
            listPicker.SelectionChanged += new SelectionChangedEventHandler(delegate
            {
                if (listcb.IsChecked == false)
                    pi.SetValue(taskCopy, null, null);
                else
                    pi.SetValue(taskCopy, App.ViewModel.TaskLists[listPicker.SelectedIndex].ID, null);
            });
            innerPanel.Children.Add(listcb);
            innerPanel.Children.Add(listPicker);
            return innerPanel;
        }