我目前有一个自定义TemplateSelector,为第一个项目选择一个不同的(更大)模板,但是这里指定的流程:
<GroupStyle.Panel> <ItemsPanelTemplate> <q42:WrapPanel OrIEntation="Horizontal" WIDth="440" margin="0,80,0"/> <!-- also trIEd VariableSizeDWrapGrID --> </ItemsPanelTemplate></GroupStyle.Panel>
类似地包装项目1到3,但是然后将项目4放置在项目6的位置,而不填写项目4和5.
问题变成;我如何编写类似于CSS的代码:
.item { display: inline-block; }.item1 { float: left; }
,这将使物品像我想要的那样流动?
解决方法 Andreas Hammar将我联系到一个有效的解决方案:using System.Collections.Generic;using Application1.Data;using windows.Foundation;using windows.UI.Xaml;using windows.UI.Xaml.Controls;namespace Application1{ public class MyGrIDVIEw : GrIDVIEw { int _rowVal; int _colVal; Readonly List<Size> _sequence; public MyGrIDVIEw() { _sequence = new List<Size> { LayoutSizes.PrimaryItem,LayoutSizes.SecondarySmallitem,LayoutSizes.OtherSmallitem,// 5 LayoutSizes.OtherSmallitem,LayoutSizes.SecondaryTallitem,// 7 LayoutSizes.OtherSmallitem,// 9 LayoutSizes.OtherSmallitem,// 11 LayoutSizes.SecondarySmallitem,LayoutSizes.OtherSmallitem }; } protected overrIDe voID PrepareContainerForItemOverrIDe(DependencyObject element,object item) { base.PrepareContainerForItemOverrIDe(element,item); var dataItem = item as SampleDataItem; var index = -1; if (dataItem != null) { index = dataItem.Group.Items.IndexOf(dataItem); } if (index >= 0 && index < _sequence.Count) { _colVal = (int) _sequence[index].WIDth; _rowVal = (int) _sequence[index].Height; } else { _colVal = (int) LayoutSizes.OtherSmallitem.WIDth; _rowVal = (int) LayoutSizes.OtherSmallitem.Height; } VariableSizeDWrapGrID.Setrowspan(element as UIElement,_rowVal); VariableSizeDWrapGrID.SetColumnSpan(element as UIElement,_colVal); } } public static class LayoutSizes { public static Size PrimaryItem = new Size(6,2); public static Size SecondarySmallitem = new Size(3,1); public static Size SecondaryTallitem = new Size(2,2); public static Size OtherSmallitem = new Size(2,1); }}
<local:MyGrIDVIEw.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel OrIEntation="Horizontal"/> </ItemsPanelTemplate> </local:MyGrIDVIEw.ItemsPanel> <local:MyGrIDVIEw.GroupStyle> <GroupStyle> <GroupStyle.headerTemplate> <DataTemplate> <GrID margin="1,6"> <button automationPropertIEs.name="Group Title" Content="{Binding Title}" Click="header_Click" Style="{StaticResource TextbuttonStyle}"/> </GrID> </DataTemplate> </GroupStyle.headerTemplate> <GroupStyle.Panel> <ItemsPanelTemplate> <VariableSizeDWrapGrID ItemWIDth="80" ItemHeight="160" OrIEntation="Vertical" margin="0,0" MaximumRowsOrColumns="3"/> </ItemsPanelTemplate> </GroupStyle.Panel> </GroupStyle> </local:MyGrIDVIEw.GroupStyle></local:MyGrIDVIEw>总结
以上是内存溢出为你收集整理的在GridView(XAML)组中包装/浮动项目’float:left’在最上面的项目上全部内容,希望文章能够帮你解决在GridView(XAML)组中包装/浮动项目’float:left’在最上面的项目上所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)