Wrappanel 和滚动查看器问题
我需要显示Buttons
,用户可以使用它来添加控件。 按钮
按组进行分类。这是我拥有的 XAML -
<ScrollViewer
VerticalScrollBarVisibility="Auto">
<GroupBox
Name="maingroup"
Header="Click To Add Controls"
BorderBrush="Transparent">
<Grid>
<Grid.RowDefinitions>
<RowDefinition
Height="*" />
<RowDefinition
Height="90" />
</Grid.RowDefinitions>
<GroupBox
Grid.Row="0"
Name="groupVarControls"
Header="{Binding Path=GroupBoxHeaderText, Mode=OneWay}">
<ScrollViewer
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Hidden">
<WrapPanel
Margin="7,7,0,0"
AllowDrop="False">
<syncfusion:RibbonButton
SizeForm="Large"
Name="BarControl"
LargeIcon="Images\Bar.png"
Label="Bar"
AllowDrop="True">
</syncfusion:RibbonButton>
<!-- 10 More buttons -->
</WrapPanel>
</ScrollViewer>
</GroupBox>
<GroupBox
Grid.Row="1"
Name="groupVarControls2"
Visibility="{Binding Path=GroupBoxVisibility, Mode=OneWay}"
Header="Click to Add control">
<ScrollViewer
VerticalScrollBarVisibility="Hidden"
HorizontalScrollBarVisibility="Auto">
<WrapPanel
Margin="7,7,0,0"
AllowDrop="False">
<syncfusion:RibbonButton
SizeForm="Large"
Name="ClockControl"
AllowDrop="False"
LargeIcon="Images\Clock.png"
Label="Clock"
Click="ClockControl_Click" />
<!-- More buttons -->
</WrapPanel>
</ScrollViewer>
</GroupBox>
</Grid>
</GroupBox>
</ScrollViewer>
我想要一个对于 WrapPanel
和单独的水平 ScrollBar
通用的垂直 ScrollBar
。由于此 XAML 滚动条无法正确显示,ScrollViewer
会导致换行被“禁用”,它只会将我的控件留在单个行
(或列
)中code>),并立即使用 ScrollBar
。
我无法为 WrapPanel
提供固定的 widht
,因为此控件将显示在 DockPanel
(类似于 VS 工具箱)和用户中可以接受它。
有什么想法吗?
I need to display Buttons
, which user can use to add controls. Buttons
are categorized in groups. Here is the XAML I am having -
<ScrollViewer
VerticalScrollBarVisibility="Auto">
<GroupBox
Name="maingroup"
Header="Click To Add Controls"
BorderBrush="Transparent">
<Grid>
<Grid.RowDefinitions>
<RowDefinition
Height="*" />
<RowDefinition
Height="90" />
</Grid.RowDefinitions>
<GroupBox
Grid.Row="0"
Name="groupVarControls"
Header="{Binding Path=GroupBoxHeaderText, Mode=OneWay}">
<ScrollViewer
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Hidden">
<WrapPanel
Margin="7,7,0,0"
AllowDrop="False">
<syncfusion:RibbonButton
SizeForm="Large"
Name="BarControl"
LargeIcon="Images\Bar.png"
Label="Bar"
AllowDrop="True">
</syncfusion:RibbonButton>
<!-- 10 More buttons -->
</WrapPanel>
</ScrollViewer>
</GroupBox>
<GroupBox
Grid.Row="1"
Name="groupVarControls2"
Visibility="{Binding Path=GroupBoxVisibility, Mode=OneWay}"
Header="Click to Add control">
<ScrollViewer
VerticalScrollBarVisibility="Hidden"
HorizontalScrollBarVisibility="Auto">
<WrapPanel
Margin="7,7,0,0"
AllowDrop="False">
<syncfusion:RibbonButton
SizeForm="Large"
Name="ClockControl"
AllowDrop="False"
LargeIcon="Images\Clock.png"
Label="Clock"
Click="ClockControl_Click" />
<!-- More buttons -->
</WrapPanel>
</ScrollViewer>
</GroupBox>
</Grid>
</GroupBox>
</ScrollViewer>
I want a vertical ScrollBar
common for both WrapPanel
's and individual horizontal ScrollBar
's. With this XAML scrollbars are not coming correctly, ScrollViewer
causes the wrapping to be "disabled", it just leaves my controls in a single row
(or column
), and uses a ScrollBar
right away.
I can't give a fixed widht
to WrapPanel
's as this control will be displayed in a DockPanel
(similar to VS toolbox) and user can cnage it.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此代码将在需要时显示一个垂直滚动条和两个水平滚动条。在代码中,您需要将环绕面板的 MinWidth 设置为最宽子面板的宽度。您可能可以在处理用户添加或删除控件时的代码中轻松地做到这一点。
This code will show one vertical scrollbar and two horizontal scrollbars when needed. In your code you need to set the MinWidth for the wrap panels to the width of the widest child. You probably can do that easily in your code that handles when a user adds or removes a control.