开发者

WPF create a list of items that scroll vertically then horizontally

开发者 https://www.devze.com 2022-12-22 06:08 出处:网络
How can I go about creating a control that has items in item that list vertically, but only to the height of the control, then start at the top of the second column?

How can I go about creating a control that has items in item that list vertically, but only to the height of the control, then start at the top of the second column?

Sort of like the windows explorer look and feel.

I am using a WrapPanel at the moment, but I cannot开发者_运维知识库 figure out how to make it scroll horizontally...

Any help here is greatly appreciated

Cheers, Mark


Enclose a WrapPanel with vertical orientation within a ScrollViewer with VerticalScrollbarVisibility set to Disabled.

Paste this into Kaxaml and you'll see:

<Page
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Page.Resources>
    <Style TargetType="{x:Type Button}">
      <Style.Setters>
        <Setter Property="Width" Value="50"/>
        <Setter Property="Height" Value="50"/>
      </Style.Setters>
    </Style>
  </Page.Resources>
  <Grid Margin="200, 100">
    <ScrollViewer VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Visible" MaxWidth="200">
    <WrapPanel Orientation="Vertical">
      <Button/>
      <Button/>
      <Button/>
      <Button/>
      <Button/>
      <Button/>
      <Button/>
      <Button/>
      <Button/>
    </WrapPanel>
    </ScrollViewer>
  </Grid>
</Page>


Sounds alot like a UniformGrid or a WrapPanel to me check this blog, he has some nice demos of the built-in layout panels

0

精彩评论

暂无评论...
验证码 换一张
取 消