在wpf中设置ScrollViewer的滚动范围

发布于 2024-10-04 16:16:23 字数 836 浏览 0 评论 0原文

我在 WPF 中使用 ScrollViewer。我的 XAML 如下::

<ScrollViewer HorizontalScrollBarVisibility="Auto" x:Name="ScrollProcess">

   <ItemsControl ItemsSource="{Binding Steps}">

        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Orientation="Horizontal"></StackPanel>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>

        <ItemsControl.ItemTemplate>
            <DataTemplate>
                  <TextBlock>Test Text</TextBlock>
            </DataTemplate>
        </ItemsControl.ItemTemplate>

    </ItemsControl>

</ScrollViewer>

我想知道如何将滚动条设置为选定的 TextBlock (假设显示大约 25 个 TextBlock。我必须将滚动条移动到第 15 个 TextBlock)

I am using a ScrollViewer in WPF. My XAML is as follows ::

<ScrollViewer HorizontalScrollBarVisibility="Auto" x:Name="ScrollProcess">

   <ItemsControl ItemsSource="{Binding Steps}">

        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Orientation="Horizontal"></StackPanel>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>

        <ItemsControl.ItemTemplate>
            <DataTemplate>
                  <TextBlock>Test Text</TextBlock>
            </DataTemplate>
        </ItemsControl.ItemTemplate>

    </ItemsControl>

</ScrollViewer>

I want to know how to set the scrollbar to the selected TextBlock (say around 25 TextBlocks gets displayed. I have to move the scrollbar to 15th TextBlock)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

泪眸﹌ 2024-10-11 16:16:23
textBox15.BringIntoView();

FrameworkElement.BringIntoView 方法

textBox15.BringIntoView();

FrameworkElement.BringIntoView Method

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文