wpf - Uniformgrid 按列表计数动态排列,如何填充左侧
问题描述
这里列表计数= 11
我要从左到右填充
但是当我申请时并没有什么不同
WPF 代码
<Border x:Name="LogoListBorder" BorderBrush="#c7c7c7" BorderThickness="1">
<ItemsControl x:Name="ControlLogo" ItemsSource="{Binding}"
VerticalAlignment="Top" FlowDirection="LeftToRight" >
<ItemsControl.ItemTemplate >
<DataTemplate DataType="{x:Type mo:LogoModel}">
<Grid>
<Button x:Name="LogoButton"
Tag="{Binding LogoIndex}"
Width="{Binding LogoWidth}"
Height="{Binding LogoHeight}"
Panel.ZIndex="0" >
<Grid x:Name="LogoGrid" >
<Image
Width="{Binding LogoWidth}"
Height="{Binding LogoHeight}"
Source="{Binding LogoImage}"
Tag="{Binding LogoCode}"
RenderOptions.BitmapScalingMode="Fant"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
<TextBlock Text="{Binding LogoName}"
VerticalAlignment="Center"
HorizontalAlignment="Center"
TextAlignment="Center"
FontWeight="Bold"
FontSize="19" />
</Grid>
</Button>
<Grid x:Name="EveningGrid"
Width="{Binding EveningGridWidth}"
Height="{Binding EveningGridHeight}"
VerticalAlignment="Top"
HorizontalAlignment="Left"
Panel.ZIndex="1">
<Border BorderThickness="1"
Margin="{Binding
EveningBorderMargin}">
</Border>
</Grid>
<!--#endregion-->
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<!-- Behind Code UniformGrid-->
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="FrameworkElement.Margin" Value="0"/>
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
</Border>
Uniformgrid 动态集背后
FrameworkElementFactory ug = new FrameworkElementFactory(typeof(UniformGrid));
ControlLogo.ItemsPanel = new ItemsPanelTemplate(ug);
if (LogoListCount < 11)
{
ug.SetValue(UniformGrid.RowsProperty, 10); //Row Setting
ug.SetValue(UniformGrid.ColumnsProperty, 1); //Row Setting
}
else if (LogoListCount <= 20 && LogoListCount >= 11)
{
ug.SetValue(UniformGrid.ColumnsProperty, 2; //Row Setting
ug.SetValue(UniformGrid.RowsProperty, 10); //Row Setting
}
else
{
ug.SetValue(UniformGrid.RowsProperty, 10); //Row Setting
ug.SetValue(UniformGrid.ColumnsProperty, 3); //Row Setting
}
但是......就像图片一样,为什么不填充左行第 7~11 行?我不.. 不工作 UniformGrid FlowDirection LeftToRight.. 我想填充左行 LineNumber 7~11, Ater next clomn
解决方案
推荐阅读
- java - 计算轴对齐立方体的并集体积
- azure-devops - Azure Devops 发布管道 - git 克隆由于文件名长而失败
- asp.net - 无法绑定到 IPv6 环回接口上的 http://localhost:5000:
- java - 如何使用 SQLite3 获取 jdbc 中最后插入的 id?
- django - How to install Django+Postgres on Docker using base image Alpine:3.14
- nginx - NGINX 为什么我从子文件夹到 IP 地址的重定向不起作用?
- .net - 设置不记名令牌 HttpClient .NET 不起作用
- python - 找不到模块“...”(或其依赖项之一)。尝试使用带有构造函数语法的完整路径
- python - python -m path.to.file 而不是 python path/to/file.py
- reactjs - 延迟渲染反应