element.HeightRequest = 250;
- element.ItemsLayout = ListItemsLayout.VerticalList;
+ element.ItemsLayout = ListItemsLayout.Vertical;
}
}
}
\ No newline at end of file
{
descriptionLabel,
GalleryBuilder.NavButton("Vertical List (Code)", () =>
- new TemplateCodeCollectionViewGallery(ListItemsLayout.VerticalList), Navigation),
+ new TemplateCodeCollectionViewGallery(ListItemsLayout.Vertical), Navigation),
GalleryBuilder.NavButton("Horizontal List (Code)", () =>
- new TemplateCodeCollectionViewGallery(ListItemsLayout.HorizontalList), Navigation),
+ new TemplateCodeCollectionViewGallery(ListItemsLayout.Horizontal), Navigation),
GalleryBuilder.NavButton("Vertical Grid (Code)", () =>
new TemplateCodeCollectionViewGridGallery (), Navigation),
GalleryBuilder.NavButton("Horizontal Grid (Code)", () =>
// so we can demonstrate switching between them
descriptionLabel,
GalleryBuilder.NavButton("Vertical List (Code)", () =>
- new TextCodeCollectionViewGallery(ListItemsLayout.VerticalList), Navigation),
+ new TextCodeCollectionViewGallery(ListItemsLayout.Vertical), Navigation),
GalleryBuilder.NavButton("Horizontal List (Code)", () =>
- new TextCodeCollectionViewGallery(ListItemsLayout.HorizontalList), Navigation),
+ new TextCodeCollectionViewGallery(ListItemsLayout.Horizontal), Navigation),
GalleryBuilder.NavButton("Vertical Grid (Code)", () =>
new TextCodeCollectionViewGridGallery(), Navigation),
GalleryBuilder.NavButton("Horizontal Grid (Code)", () =>
{
descriptionLabel,
GalleryBuilder.NavButton("Expanding Text (Vertical List)", () =>
- new DynamicItemSizeGallery(ListItemsLayout.VerticalList), Navigation),
+ new DynamicItemSizeGallery(ListItemsLayout.Vertical), Navigation),
GalleryBuilder.NavButton("Expanding Text (Horizontal List)", () =>
- new DynamicItemSizeGallery(ListItemsLayout.HorizontalList), Navigation),
+ new DynamicItemSizeGallery(ListItemsLayout.Horizontal), Navigation),
GalleryBuilder.NavButton("ItemSizing Strategy", () =>
new VariableSizeTemplateGridGallery (ItemsLayoutOrientation.Horizontal), Navigation)
}
{
descriptionLabel,
GalleryBuilder.NavButton("Propagate FlowDirection", () =>
- new PropagateCodeGallery(ListItemsLayout.VerticalList), Navigation),
+ new PropagateCodeGallery(ListItemsLayout.Vertical), Navigation),
}
}
};
{
descriptionLabel,
GalleryBuilder.NavButton("ScrollTo Index (Code, Horizontal List)", () =>
- new ScrollToCodeGallery(ListItemsLayout.HorizontalList), Navigation),
+ new ScrollToCodeGallery(ListItemsLayout.Horizontal), Navigation),
GalleryBuilder.NavButton("ScrollTo Index (Code, Vertical List)", () =>
- new ScrollToCodeGallery(ListItemsLayout.VerticalList), Navigation),
+ new ScrollToCodeGallery(ListItemsLayout.Vertical), Navigation),
GalleryBuilder.NavButton("ScrollTo Index (Code, Horizontal Grid)", () =>
new ScrollToCodeGallery(new GridItemsLayout(3, ItemsLayoutOrientation.Horizontal)),
Navigation),
Navigation),
GalleryBuilder.NavButton("ScrollTo Item (Code, Horizontal List)", () =>
- new ScrollToCodeGallery(ListItemsLayout.HorizontalList, ScrollToMode.Element,
+ new ScrollToCodeGallery(ListItemsLayout.Horizontal, ScrollToMode.Element,
ExampleTemplates.ScrollToItemTemplate), Navigation),
GalleryBuilder.NavButton("ScrollTo Item (Code, Vertical List)", () =>
- new ScrollToCodeGallery(ListItemsLayout.VerticalList, ScrollToMode.Element,
+ new ScrollToCodeGallery(ListItemsLayout.Vertical, ScrollToMode.Element,
ExampleTemplates.ScrollToItemTemplate), Navigation),
GalleryBuilder.NavButton("ScrollTo Item (Code, Horizontal Grid)", () =>
new ScrollToCodeGallery(new GridItemsLayout(3, ItemsLayoutOrientation.Horizontal),
{
descriptionLabel,
GalleryBuilder.NavButton("Snap Points (Code, Horizontal List)", () =>
- new SnapPointsCodeGallery(ListItemsLayout.HorizontalList as ItemsLayout), Navigation),
+ new SnapPointsCodeGallery(ListItemsLayout.Horizontal as ItemsLayout), Navigation),
GalleryBuilder.NavButton("Snap Points (Code, Vertical List)", () =>
- new SnapPointsCodeGallery(ListItemsLayout.VerticalList as ItemsLayout), Navigation),
+ new SnapPointsCodeGallery(ListItemsLayout.Vertical as ItemsLayout), Navigation),
GalleryBuilder.NavButton("Snap Points (Code, Horizontal Grid)", () =>
new SnapPointsCodeGallery(new GridItemsLayout(2, ItemsLayoutOrientation.Horizontal)), Navigation),
GalleryBuilder.NavButton("Snap Points (Code, Vertical Grid)", () =>
{
descriptionLabel,
GalleryBuilder.NavButton("Vertical List Spacing", () =>
- new SpacingGallery (ListItemsLayout.VerticalList), Navigation),
+ new SpacingGallery (ListItemsLayout.Vertical), Navigation),
GalleryBuilder.NavButton("Horizontal List Spacing", () =>
- new SpacingGallery (ListItemsLayout.HorizontalList), Navigation),
+ new SpacingGallery (ListItemsLayout.Horizontal), Navigation),
GalleryBuilder.NavButton("Vertical Grid Spacing", () =>
new SpacingGallery (new GridItemsLayout(3, ItemsLayoutOrientation.Vertical)), Navigation),
GalleryBuilder.NavButton("Horizontal Grid Spacing", () =>
"Visual",
new System.ComponentModel.TypeConverterAttribute(typeof(VisualDesignTypeConverter))));
+ AddCallback(typeof(ItemsView), builder => builder.AddCustomAttributes(
+ "ItemsLayout",
+ new System.ComponentModel.TypeConverterAttribute(typeof(ItemsLayoutDesignTypeConverter))));
+
// TODO: OnPlatform/OnIdiom
// These two should be proper markup extensions, to follow WPF syntax for those.
// That would allow us to turn on XAML validation, which otherwise fails.
--- /dev/null
+namespace Xamarin.Forms.Core.Design
+{
+ using System;
+ using System.Collections.Generic;
+ using System.ComponentModel;
+
+ public class ItemsLayoutDesignTypeConverter : TypeConverter
+ {
+ public ItemsLayoutDesignTypeConverter()
+ {
+ }
+
+ protected StandardValuesCollection Values
+ {
+ get;
+ set;
+ }
+
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
+ {
+ // This tells XAML this converter can be used to process strings
+ // Without this the values won't show up as hints
+ if (sourceType == typeof(string))
+ {
+ return true;
+ }
+
+ return base.CanConvertFrom(context, sourceType);
+ }
+
+ public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
+ {
+ if (Values == null)
+ {
+ var names = new List<string>() { "VerticalList", "HorizontalList" };
+ Values = new StandardValuesCollection(names);
+ }
+
+ return Values;
+ }
+
+ public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
+ {
+ return false;
+ }
+
+ public override bool GetStandardValuesSupported(ITypeDescriptorContext context)
+ {
+ return true;
+ }
+ }
+}
\ No newline at end of file
<ProjectGuid>{98637471-8E5C-4DDE-89CA-2EAA664FB0EF}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace></RootNamespace>
- <TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
+ <RootNamespace>
+ </RootNamespace>
+ <TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<LogicalName>Xamarin.Forms.toolbox.xml</LogicalName>
</EmbeddedResource>
</ItemGroup>
+ <ItemGroup>
+ <Compile Include="ItemsLayoutDesignTypeConverter.cs" />
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- Ensure that all images in the 'mac' and 'win' subdirectories are included as embedded resources -->
<!-- using a defined format. That format is "{platform}.{imagename}". We will look up images using -->
namespace Xamarin.Forms
{
+ [TypeConverter(typeof(ItemsLayoutTypeConverter))]
public interface IItemsLayout : INotifyPropertyChanged {}
}
\ No newline at end of file
--- /dev/null
+using System;
+
+namespace Xamarin.Forms
+{
+ [Xaml.TypeConversion(typeof(IItemsLayout))]
+ public class ItemsLayoutTypeConverter : TypeConverter
+ {
+ public override object ConvertFromInvariantString(string value)
+ {
+ if (value == "HorizontalList")
+ {
+ return ListItemsLayout.Horizontal;
+ }
+
+ if (value == "VerticalList")
+ {
+ return ListItemsLayout.Vertical;
+ }
+
+ throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(IItemsLayout)}");
+ }
+ }
+}
\ No newline at end of file
public static readonly BindableProperty ItemsLayoutProperty =
BindableProperty.Create(nameof(ItemsLayout), typeof(IItemsLayout), typeof(ItemsView),
- ListItemsLayout.VerticalList);
+ ListItemsLayout.Vertical);
public IItemsLayout ItemsLayout
{
-namespace Xamarin.Forms
+using System;
+
+namespace Xamarin.Forms
{
public class ListItemsLayout : ItemsLayout
{
- // TODO hartez 2018/08/29 17:28:42 Consider changing this name to LinearItemsLayout; not everything using it is a list (e.g., Carousel)
public ListItemsLayout(ItemsLayoutOrientation orientation) : base(orientation)
{
}
- // TODO hartez 2018/05/31 15:56:23 Should these just be called Vertical and Horizontal (without List)?
- public static readonly IItemsLayout VerticalList = new ListItemsLayout(ItemsLayoutOrientation.Vertical);
- public static readonly IItemsLayout HorizontalList = new ListItemsLayout(ItemsLayoutOrientation.Horizontal);
+ public static readonly IItemsLayout Vertical = new ListItemsLayout(ItemsLayoutOrientation.Vertical);
+ public static readonly IItemsLayout Horizontal = new ListItemsLayout(ItemsLayoutOrientation.Horizontal);
// TODO hartez 2018/08/29 20:31:54 Need something like these previous two, but as a carousel default