Beispiel #1
0
        public void ValidateBindableProperties()
        {
            var layout = new StackLayout
            {
                IsPlatformEnabled = true,
            };

            // EmptyView
            object emptyView = new object();

            BindableLayout.SetEmptyView(layout, emptyView);

            Assert.AreEqual(emptyView, BindableLayout.GetEmptyView(layout));
            Assert.AreEqual(emptyView, layout.GetValue(BindableLayout.EmptyViewProperty));

            // EmptyViewTemplateProperty
            DataTemplate emptyViewTemplate = new DataTemplate(typeof(Label));

            BindableLayout.SetEmptyViewTemplate(layout, emptyViewTemplate);

            Assert.AreEqual(emptyViewTemplate, BindableLayout.GetEmptyViewTemplate(layout));
            Assert.AreEqual(emptyViewTemplate, layout.GetValue(BindableLayout.EmptyViewTemplateProperty));


            // ItemsSourceProperty
            IEnumerable itemsSource = new object[0];

            BindableLayout.SetItemsSource(layout, itemsSource);

            Assert.AreEqual(itemsSource, BindableLayout.GetItemsSource(layout));
            Assert.AreEqual(itemsSource, layout.GetValue(BindableLayout.ItemsSourceProperty));

            // ItemTemplateProperty
            DataTemplate itemTemplate = new DataTemplate(typeof(Label));

            BindableLayout.SetItemTemplate(layout, itemTemplate);

            Assert.AreEqual(itemTemplate, BindableLayout.GetItemTemplate(layout));
            Assert.AreEqual(itemTemplate, layout.GetValue(BindableLayout.ItemTemplateProperty));


            // ItemTemplateSelectorProperty
            var itemTemplateSelector = new DataTemplateSelectorFrame();

            BindableLayout.SetItemTemplateSelector(layout, itemTemplateSelector);

            Assert.AreEqual(itemTemplateSelector, BindableLayout.GetItemTemplateSelector(layout));
            Assert.AreEqual(itemTemplateSelector, layout.GetValue(BindableLayout.ItemTemplateSelectorProperty));
        }
 public static TLayout EmptyViewTemplate <TLayout>(this TLayout layout, Func <object> loadTemplate) where TLayout : Layout <View>
 {
     BindableLayout.SetEmptyViewTemplate(layout, new DataTemplate(loadTemplate)); return(layout);
 }
 public static TLayout EmptyViewTemplate <TLayout>(this TLayout layout, DataTemplate template) where TLayout : Layout <View>
 {
     BindableLayout.SetEmptyViewTemplate(layout, template); return(layout);
 }