コード例 #1
0
		public MainListPage ()
		{
			Title = "Roget's 1911";
			NavigationPage.SetHasNavigationBar (this, true);
			listView = new ListView { RowHeight = 40 };
			
			listView.ItemTemplate = new DataTemplate (typeof (TextCell)) {
				Bindings = {
					{ TextCell.TextProperty, new Binding ("Name") }
				}
			};

			listView.ItemSelected += (sender, e) => {
				if (e.SelectedItem == null) return;
				listView.SelectedItem = null; // clear out for next rendering of list

				var @class = (RogetClass)e.SelectedItem;
				var categoryPage = new SectionListPage();
				categoryPage.Title = @class.Name;
				categoryPage.BindingContext = @class.Sections;
				Navigation.PushAsync(categoryPage);
			};

			// HACK: workaround issue #894 for now
			if (Device.OS == TargetPlatform.iOS)
				listView.ItemsSource = new string [1] {""};

			Content = new StackLayout {
				VerticalOptions = LayoutOptions.FillAndExpand,
				Children = {listView}
			};
		}
コード例 #2
0
        public SectionListPage()
        {
            NavigationPage.SetHasNavigationBar(this, true);
            if (Device.OS != TargetPlatform.Windows)
            { // HACK: this doesn't look right on Windows
                listView = new ListView {
                    RowHeight = 40
                };
            }
            else
            {
                listView = new ListView();
            }

            listView.SetBinding(ListView.ItemsSourceProperty, ".");
            listView.ItemTemplate = new DataTemplate(typeof(TextCell))
            {
                Bindings =
                {
                    { TextCell.TextProperty, new Binding("Name") }
                }
            };

            listView.ItemSelected += (sender, e) => {
                if (e.SelectedItem == null)
                {
                    return;
                }
                listView.SelectedItem = null;                 // clear out for next rendering of list

                var section = (RogetSection)e.SelectedItem;
                if (section.Sections.Count == 0)
                {                 // show workds
                    var categoryListPage = new CategoryListPage(section);
                    categoryListPage.Title = section.Name;
                    Navigation.PushAsync(categoryListPage);
                }
                else                     // show more sections hierarchy
                {
                    var sectionListPage = new SectionListPage();
                    sectionListPage.Title          = section.Name;
                    sectionListPage.BindingContext = section.Sections;
                    Navigation.PushAsync(sectionListPage);
                }
            };

            Content = new StackLayout {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children        = { listView }
            };
        }
コード例 #3
0
        public MainListPage()
        {
            Title = "Roget's 1911";
            NavigationPage.SetHasNavigationBar(this, true);
            if (Device.OS != TargetPlatform.Windows)
            { // HACK: this doesn't look right on Windows
                listView = new ListView {
                    RowHeight = 40
                };
            }
            else
            {
                listView = new ListView();
            }
            listView.ItemTemplate = new DataTemplate(typeof(TextCell))
            {
                Bindings =
                {
                    { TextCell.TextProperty, new Binding("Name") }
                }
            };

            listView.ItemSelected += (sender, e) => {
                if (e.SelectedItem == null)
                {
                    return;
                }
                listView.SelectedItem = null;                 // clear out for next rendering of list

                var @class       = (RogetClass)e.SelectedItem;
                var categoryPage = new SectionListPage();
                categoryPage.Title          = @class.Name;
                categoryPage.BindingContext = @class.Sections;
                Navigation.PushAsync(categoryPage);
            };

            // HACK: workaround issue #894 for now
            if (Device.OS == TargetPlatform.iOS)
            {
                listView.ItemsSource = new string [1] {
                    ""
                }
            }
            ;

            Content = new StackLayout {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children        = { listView }
            };
        }
コード例 #4
0
		public SectionListPage ()
		{
			NavigationPage.SetHasNavigationBar (this, true);
            if (Device.OS != TargetPlatform.Windows)
            { // HACK: this doesn't look right on Windows
                listView = new ListView { RowHeight = 40 };
            }
            else
            {
                listView = new ListView();
            }

			listView.SetBinding (ListView.ItemsSourceProperty, ".");
			listView.ItemTemplate = new DataTemplate (typeof (TextCell)) {
				Bindings = {
					{ TextCell.TextProperty, new Binding ("Name") }
				}
			};

			listView.ItemSelected += (sender, e) => {
				if (e.SelectedItem == null) return;
				listView.SelectedItem = null; // clear out for next rendering of list

				var section = (RogetSection)e.SelectedItem;
				if (section.Sections.Count == 0)
				{ // show workds
					var categoryListPage = new CategoryListPage(section);
					categoryListPage.Title = section.Name;
					Navigation.PushAsync(categoryListPage);
				} else { // show more sections hierarchy
					var sectionListPage = new SectionListPage();
					sectionListPage.Title = section.Name;
					sectionListPage.BindingContext = section.Sections;
					Navigation.PushAsync(sectionListPage);
				}
			};

			Content = new StackLayout {
				VerticalOptions = LayoutOptions.FillAndExpand,
				Children = {listView}
			};

		}
コード例 #5
0
        public SectionListPage()
        {
            NavigationPage.SetHasNavigationBar(this, true);
            listView = new ListView {
                RowHeight = 40
            };

            listView.SetBinding(ListView.ItemsSourceProperty, ".");
            listView.ItemTemplate = new DataTemplate(typeof(TextCell))
            {
                Bindings =
                {
                    { TextCell.TextProperty, new Binding("Name") }
                }
            };

            listView.ItemSelected += (sender, e) => {
                var section = (RogetSection)e.SelectedItem;
                if (section.Sections.Count == 0)
                {                 // show workds
                    var categoryListPage = new CategoryListPage(section);
                    categoryListPage.Title = section.Name;
                    Navigation.PushAsync(categoryListPage);
                }
                else                     // show more sections hierarchy
                {
                    var sectionListPage = new SectionListPage();
                    sectionListPage.Title          = section.Name;
                    sectionListPage.BindingContext = section.Sections;
                    Navigation.PushAsync(sectionListPage);
                }
            };

            Content = new StackLayout {
                VerticalOptions = LayoutOptions.FillAndExpand,
                Children        = { listView }
            };
        }