Ejemplo n.º 1
0
        public MasterSamplePage(MasterSample sampleList)
        {
            this.sampleList = sampleList;

            Title = Device.OS == TargetPlatform.Android ? "  " + sampleList.Title : sampleList.Title;

            if (sampleList.Samples.Count == 1)
            {
                var type = Type.GetType(sampleList.Samples[0].Type);
                if (type == null)
                {
                    Detail = new EmptyContent();
                }
                else
                {
                    var samplePage = Activator.CreateInstance(type) as SamplePage;
                    Detail = samplePage;
                }
            }
            else if (sampleList.Samples.Count > 1)
            {
                listView = new ListView
                {
                    ItemsSource     = sampleList.Samples,
                    RowHeight       = 40,
                    ItemTemplate    = new DataTemplate(typeof(SampleListCell)),
                    BackgroundColor = Color.Gray
                };

                Master = listView;

                listView.ItemSelected += (sender, args) =>
                {
                    if (listView.SelectedItem == null)
                    {
                        return;
                    }

                    var sampleDetails = args.SelectedItem as SampleDetails;

                    var type = Type.GetType(sampleDetails.Type);
                    if (type == null)
                    {
                        Detail = new EmptyContent();
                    }
                    else
                    {
                        var samplePage = Activator.CreateInstance(type) as SamplePage;
                        Detail = samplePage;
                    }
                };

                SelectSample();
            }
        }
        public MasterSamplePage(MasterSample sampleList)
        {
            this.sampleList = sampleList;

            Title = Device.OS == TargetPlatform.Android ? "  " + sampleList.Title : sampleList.Title;

            if (sampleList.Samples.Count == 1)
            {
                var type = Type.GetType(sampleList.Samples[0].Type);
                if (type == null)
                {
                    Detail = new EmptyContent();
                }
                else
                {
                    var samplePage = Activator.CreateInstance(type) as SamplePage;
                    Detail = samplePage;
                }
            }
            else if (sampleList.Samples.Count > 1)
            {
                listView = new ListView
                {
                    ItemsSource = sampleList.Samples,
                    RowHeight = 40,
                    ItemTemplate = new DataTemplate(typeof(SampleListCell)),
                    BackgroundColor = Color.Gray
                };

                Master = listView;

                listView.ItemSelected += (sender, args) =>
                {
                    if (listView.SelectedItem == null)
                        return;

                    var sampleDetails = args.SelectedItem as SampleDetails;

                    var type = Type.GetType(sampleDetails.Type);
                    if (type == null)
                    {
                        Detail = new EmptyContent();
                    }
                    else
                    {
                        var samplePage = Activator.CreateInstance(type) as SamplePage;
                        Detail = samplePage;
                    }
                };

                SelectSample();
            }
        }
        public MasterSamplePage(MasterSample sampleList)
        {
            this.sampleList = sampleList;

            Title = Device.OS == TargetPlatform.Android ? "  " + sampleList.Title : sampleList.Title;

            if (sampleList.Samples.Count == 1)
            {
                var type = Type.GetType(sampleList.Samples[0].Type);
                if (type == null)
                {
                    Detail = new EmptyContent();
                }
                else
                {
                    var samplePage = Activator.CreateInstance(type) as SamplePage;
                    Detail = samplePage;
                }
            }
            else if (sampleList.Samples.Count > 1)
            {
                listView = new ListView
                {
                    ItemsSource     = sampleList.Samples,
                    RowHeight       = 40,
                    ItemTemplate    = new DataTemplate(typeof(SampleListCell)),
                    BackgroundColor = Color.White,
                };

                if (Device.OS == TargetPlatform.iOS)
                {
                    StackLayout listStack = new StackLayout()
                    {
                        Padding = new Thickness(0, 0, 0, 74)
                    };
                    listStack.Children.Add(listView);
                    Master = listStack;
                }
                else
                {
                    Master = listView;
                }

                listView.SeparatorColor      = Color.FromHex("#B2B2B2");
                listView.SeparatorVisibility = DeviceExt.OnPlatform(SeparatorVisibility.Default, SeparatorVisibility.Default, SeparatorVisibility.None);
                listView.ItemSelected       += (sender, args) =>
                {
                    if (listView.SelectedItem == null)
                    {
                        return;
                    }

                    var sampleDetails = args.SelectedItem as SampleDetails;

                    var type = Type.GetType(sampleDetails.Type);
                    if (type == null)
                    {
                        Detail = new EmptyContent();
                    }
                    else
                    {
                        var samplePage = Activator.CreateInstance(type) as SamplePage;
                        Detail = samplePage;
                    }
                };

                SelectSample();
            }
        }