如何在网格中固定左右顶部的标题,并带有滚动浏览器

问题描述 投票:0回答:1
,

https://learn.microsoft.com/en-us/answers/questions/537119/how-to-freeze-grid-column-in-scrollviewer-or-achie

.这导致了我当前的结构:

<Scrollviewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible"> <Grid> <!-- Here is the left Header </Grid> <Scrollviewer HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Disabled"> <Grid> <!-- Rest of the table --> </Grid> </Scrollviewer> </Scrollviewer> nove似乎仅用于仅在一个dircetion中滚动的应用。但是就我而言,这种方法有两个问题。 水平卷轴未固定在页面底部。如果您想查看栏,则必须先滚动到底部。

目前只有左侧的标头是固定的,我不知道如何修复顶部。 If I were to exclude this part of the grid again and put it outside everything else, then the top header would be outside the horizontal scollviewer.不可能将两个标题都带入滚动浏览器并将其修复到该位置。
让任何人都知道如何解决这个问题。我可以定义滚动浏览器与其内容分开的位置。 In that case I could make one Grid, with both headers, the body of the table and the scrollviews, and then I could set the content the scrollviews so it scroll to the body of the table.

    Edit:
  1. 忘记了代码中的一个网格。这是更正的版本。
  2. <Scrollviewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible"> <Grid> <Grid> <!-- Here is the left Header --> </Grid> <Scrollviewer HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Disabled"> <Grid> <!-- Rest of the table --> </Grid> </Scrollviewer> </Grid> </Scrollviewer>
  3. 也要清楚这是我想要的

绿色是横向滚动条,垂直蓝色。两者都应始终可见。目前,我只会看到绿色的,如果我一直向下划掉。 标题(RWO X,X列)需要始终可见。同时,它们还必须包含在滚动条中。因此,左边总是可见10行,但是如果我scrolldown,我会看到12-22。

要让您入门,我的想法有点玩耍,它奏效了,但我只为水平而做到了。

您需要3ScrollBarenter image description here(对于左/顶部和内容)和2ScrollViewer

。我模拟了标题和内容,并具有一些剥离的背景(看看它如何滚动)。

重要的部分如何使用单个

ScrollBar

在许多s中滚动内容。我采用了“附加行为”解决方案。

XAML:
c# wpf xaml
1个回答
0
投票
ScrollBar

demo:


Behavior:
ScrollViewer

todo:类似地添加垂直滚动条,修复错误。

	
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.