/// <summary> /// Show the list selector /// </summary> /// <param name="title">the title</param> /// <param name="itemsSource">the items source</param> /// <param name="selectedItem">the selected item</param> /// <param name="selectionChanged">the selection changed event handler</param> /// <param name="templateName">the template name</param> /// <param name="listLayoutMode">the list layout mode</param> private void ShowListSelector( string title, IList itemsSource, object selectedItem, SelectionChangedEventHandler selectionChanged, string templateName, LongListSelectorLayoutMode listLayoutMode) { if (this.ListSelector == null) { return; } this.ListSelector.LayoutMode = listLayoutMode; var viewModel = this.DataContext as CaptionSettingsFlyoutViewModel; if (this.PageTitle != null) { this.PageTitle.Text = title.ToUpper(CultureInfo.CurrentCulture); } this.ListSelector.ItemsSource = itemsSource; this.ListSelector.SelectedItem = selectedItem; this.ListSelector.SelectionChanged += selectionChanged; if (this.LayoutRoot != null) { this.ListSelector.ItemTemplate = this.LayoutRoot.Resources[templateName] as DataTemplate; if (this.ListSelector.ItemTemplate == null) { throw new InvalidOperationException("Could not find template in LayoutRoot: " + templateName); } } VisualStateManager.GoToState(this, "ListShown", true); this.isListSelectorShown = true; }
/// <summary> /// Show the list selector /// </summary> /// <param name="title">the title</param> /// <param name="itemsSource">the items source</param> /// <param name="selectedItem">the selected item</param> /// <param name="selectionChanged">the selection changed event handler</param> /// <param name="templateName">the template name</param> /// <param name="listLayoutMode">the list layout mode</param> private void ShowListSelector( string title, IList itemsSource, object selectedItem, SelectionChangedEventHandler selectionChanged, string templateName, LongListSelectorLayoutMode listLayoutMode) { if (this.ListSelector == null) { return; } this.ListSelector.LayoutMode = listLayoutMode; var viewModel = this.DataContext as CaptionSettingsFlyoutViewModel; if (this.PageTitle != null) { this.PageTitle.Text = title.ToUpper(CultureInfo.CurrentCulture); } this.ListSelector.ItemsSource = itemsSource; this.ListSelector.SelectedItem = selectedItem; this.ListSelector.SelectionChanged += selectionChanged; if (this.LayoutRoot != null) { this.ListSelector.ItemTemplate = this.LayoutRoot.Resources[templateName] as DataTemplate; if (this.ListSelector.ItemTemplate == null) { throw new InvalidOperationException("Could not find template in LayoutRoot: " + templateName); } } VisualStateManager.GoToState(this, "ListShown", true); this.isListSelectorShown = true; }