Wpf 浮动项控件
我需要的Wpf 浮动项控件,wpf,itemscontrol,Wpf,Itemscontrol,我需要的ItemsControl必须具有: 对于ItemsPanel我设置了一个水平方向的StackPanel <Style TargetType="local:ParameterItemContainer"> <Setter Property="ItemsPanel"> <Setter.Value> <ItemsPanelTemplate> <StackPan
ItemsControl
必须具有:
对于ItemsPanel
我设置了一个水平方向的StackPanel
<Style TargetType="local:ParameterItemContainer">
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:ParameterItemContainer">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<ItemsPresenter Margin="{TemplateBinding Margin}" />
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
ParameterItemContainer
源自ItemsControl
不知道如何正确实现模板以获得与我的屏幕截图相同的外观,或者我必须重写一个函数来设置正确的布局吗?我不确定你所说的
“Floating ItemsControl”
是什么意思,但是,如果您只希望在ItemsControl
中一次显示6个项目的行,则可以使用Orientation=“Vertical”
将ItemsPanelTemplate
设置为WrapPanel
,并将其高度设置为6倍项目
<ItemsPanelTemplate>
<WrapPanel Orientation="Vertical" Height="300" />
</ItemsPanelTemplate>
这将使WPF绘图项目垂直,直到达到高度限制,然后它将水平换行到一个新列以继续绘制项目。您是否尝试过使用
Orientation=“Vertical”
将ItemsPanelTemplate设置为WrapPanel
,给它一个6倍项目的高度?非常感谢,这是对我问题的回答。好的,我把它作为一个答案贴在下面:)根据你的问题标题,我不确定这是否是你想要的,这就是为什么我把它作为一个评论贴出来。