标签: scrollviewer

如何在ListBox中禁用ScrollViewer?

我有一个ListBox.它有内部ScrollViewer,所以我可以用鼠标滚轮滚动ListBox内容.它工作正常,直到我设置包含另一个ListBox的项目模板(事实上,我有4个嵌套的ListBoxes =)).问题是内部ListBox的ScrollViewer窃取了转动事件.有没有简单的方法可以防止这种行为?


我有ListBox和ItemContainerStyle,如下所示:

<Style x:Key="ListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
    <Setter Property="BorderBrush" Value="Black"/>
     ... 
</Style>
<ListBox ItemContainerStyle="{StaticResource ListBoxItemStyle}" />
Run Code Online (Sandbox Code Playgroud)

如何在这样的资源中为ItemContainer的项边框设置样式?据我所知,ContentPresenter是ItemsControl的项容器.但它没有边框,所以我无法设计它.

wpf xaml listbox scrollviewer

11
推荐指数
2
解决办法
2万
查看次数

WPF滚动视图滚动到底部默认值

我有一个ScrollViewer包含ListBox.我希望ScrollViewer在加载视图时默认滚动到底部!这是因为最近的元素始终是最后一个元素ListBox.

有没有一种简单的方法来实现这种行为?

谢谢

wpf listbox scrollviewer

11
推荐指数
1
解决办法
1万
查看次数

Windows phone 7 scrollviewer问题

我无法在wp7中滚动页面.虽然我已经添加了scrollview它仍然无法正常工作.

<phone:PhoneApplicationPage 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="860"
x:Class="sastadeal.PhonePage1"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
Orientation="Portrait"
shell:SystemTray.IsVisible="True" Height="1768">

<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent" Height="1768">
    <ScrollViewer>

        <!--TitlePanel contains the name of the application and page title-->
<!--TitlePanel contains the name of the application and page title-->

    <Grid x:Name="ContentPanel" Margin="24,8,0,-8" Background="#FF61B1DE" Height="1768" >

        <Image Height="76" Margin="8,8,0,0" Source="logo.png" Stretch="Fill" VerticalAlignment="Top"/>

        <TextBlock HorizontalAlignment="Left" Margin="35,124,0,0" TextWrapping="Wrap" Text="Account Purpose" VerticalAlignment="Top" Foreground="Black"/>
        <ListBox x:Name="lb" Height="70" …
Run Code Online (Sandbox Code Playgroud)

silverlight xaml scrollviewer windows-phone-7

11
推荐指数
1
解决办法
5634
查看次数

如何以编程方式在Scroll viewer中添加网格

我的XAML看起来像这样

<navigation:Page x:Class="SilverlightApplication1.Home">

    <Grid x:Name="LayoutRoot">
    <!--
    <ScrollViewer>
        <Grid>
            <TextBlock Text="myTextBlock" />
        </Grid>
    </ScrollViewer>
    -->
</Grid>
Run Code Online (Sandbox Code Playgroud)

我想以编程方式通过后面的代码执行上面的注释部分.

我的代码背后看起来像这样

public partial class Home : Page
{
    public Home()
    {
        InitializeComponent();

        ScrollViewer sv = new ScrollViewer();
        Grid grid = new Grid();
        TextBlock block = new TextBlock();

        block.Text = "My Text block";
        grid.Children.Add(block);

        sv.ScrollIntoView(grid);
        LayoutRoot.Children.Add(sv);

    }
Run Code Online (Sandbox Code Playgroud)

这不起作用,因为它只显示滚动查看器但隐藏了文本块.

我错过了什么?

有没有办法使用silverlight工具包中提供的扩展方法"ScrollIntoView"以编程方式将子项添加到"ScrollViewer"控件?我没有为ScrollViewer元素找到一个名为"Children"的属性

谢谢您的帮助

silverlight grid xaml scrollviewer

11
推荐指数
1
解决办法
1万
查看次数

设置ListBox的滚动条位置

我可以以编程方式设置WPF ListBox的滚动条的位置吗?默认情况下,我希望它在中心.

wpf listbox scrollviewer

10
推荐指数
1
解决办法
2万
查看次数

Silverlight Vertical只有ScrollViewer?

有没有办法创建一个只允许内容垂直滚动的ScrollViewer?必须以与StackPanel的宽度约束到其父级(当Horizo​​ntalAlignment = Stretch时)相同的方式约束水平(宽度).

我有一个可调整大小的窗口,其中包含我想允许垂直滚动的内容.该窗口包含一个ScrollViewer.里面有很多TextBox(数据输入表格).当我在TextBox中键入大量文本时,控件只会向右和向窗口增长.如果我使用StackPanel而不是ScrollViewer,那么无论文本中有多少文本,TextBox的大小都保持不变.(但是没有垂直滚动).

我无法设置硬编码宽度,因为窗口可以调整大小.

所以基本上我想限制ScrollViewer在水平方向上增长.

谢谢

silverlight scrollviewer silverlight-4.0

10
推荐指数
1
解决办法
2361
查看次数

Scrollviewer和SIP问题(WP7.5芒果)

我正在申请一份包含注册表格的申请表.表单包含多个文本输入框,因此ScrollViewer用于允许它们全部显示在一个页面上.

以下是我正在使用的XAML代码的精简示例:

<Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
        <TextBlock x:Name="ApplicationTitle" Text="SCROLLVIEWER TEST" Style="{StaticResource PhoneTextNormalStyle}"/>
        <TextBlock x:Name="PageTitle" Text="registration" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
    </StackPanel>

    <ScrollViewer Grid.Row="1">
        <StackPanel>
            <TextBlock Text="Hello" Margin="12,0,0,0"/>
            <TextBox />
            <TextBlock Text="Hello1" Margin="12,0,0,0"/>
            <TextBox />
            <TextBlock Text="Hello2" Margin="12,0,0,0"/>
            <TextBox />
            <TextBlock Text="Hello3" Margin="12,0,0,0"/>
            <TextBox />
            <TextBlock Text="Hello4" Margin="12,0,0,0"/>
            <TextBox />
            <TextBlock Text="Hello5" Margin="12,0,0,0"/>
            <TextBox />
            <TextBlock Text="Hello6" Margin="12,0,0,0"/>
            <TextBox />
            <TextBlock Text="Hello7" Margin="12,0,0,0"/>
            <TextBox />
            <TextBlock Text="Hello8" Margin="12,0,0,0"/>
            <TextBox />
            <TextBlock Text="END" Margin="12,0,0,0"/>
            <TextBox …
Run Code Online (Sandbox Code Playgroud)

scrollviewer soft-keyboard windows-phone-7

10
推荐指数
1
解决办法
1504
查看次数

ScrollViewer无法在WPF WindowsFormHost中运行

在此输入图像描述我的WPF表单中有一个带有RichTextBox的WindowsFormHost,我已经为该WindowsFormHost提供了ScrollViewer,但它不能正常工作,WindowsFormHost不在ScrollViewer中...

我的XAML是......

<ScrollViewer Background="DarkOrange" VerticalScrollBarVisibility="Auto" Height="80" MaxHeight="85" Margin="11,243,12,218" Width="756">
        <Canvas Height="100" Name="canvas1" Width="auto" >
            <WindowsFormsHost ClipToBounds="True" Height="120" Width="715" Margin="10,5,0,0" Name="winHostTEst" Background="Gray">
                <wf:RichTextBox BackColor="Cornsilk" Text="RichTextBox" x:Name="richTbTest" BorderStyle="None" Enabled="True" ForeColor="Black" Width="550" Multiline="True" ReadOnly="True" />
            </WindowsFormsHost>
        </Canvas>
    </ScrollViewer>
Run Code Online (Sandbox Code Playgroud)

这里有两个链接解决这个问题,但我无法实现..请看看这些链接也解决我的问题..

链接是:

http://blogs.msdn.com/b/ryanvog/archive/2009/01/20/clipping-legacy-content-hosted-inside-a-wpf-scrolling-region.aspx

http://www.mycsharp.de/wbb2/thread.php?threadid=76625

提前致谢..

wpf scrollviewer windowsformshost

10
推荐指数
2
解决办法
5280
查看次数

滚动WPF DataGrid以在顶部显示所选项目

我有一个包含许多项的DataGrid,我需要以编程方式滚动到SelectedItem.我在StackOverflow和Google上搜索过,似乎解决方案是ScrollIntoView,如下所示:

grid.ScrollIntoView(grid.SelectedItem)
Run Code Online (Sandbox Code Playgroud)

向上或向下滚动DataGrid,直到所选项目处于焦点.但是,根据相对于所选项目的当前滚动位置,所选项目可能最终成为DataGrid的ScrollViewer中的最后一个可见项目.我希望所选项目将成为ScrollViewer中的第一个可见项目(假设DataGrid中有足够的行允许这样做).所以我尝试了这个:

'FindVisualChild is a custom extension method that searches in the visual tree and returns 
'the first element of the specified type
Dim sv = grid.FindVisualChild(Of ScrollViewer)
If sv IsNot Nothing Then sv.ScrollToEnd()
grid.ScrollIntoView(grid.SelectedItem)
Run Code Online (Sandbox Code Playgroud)

首先,我滚动到DataGrid的末尾,然后才滚动到SelectedItem,此时SelectedItem显示在DataGrid的顶部.

我的问题是滚动到DataGrid的末尾运行良好,但随后滚动到所选项目并不总是有效.

如何解决此问题,或者是否有其他替代策略可以滚动到顶部位置的特定记录?

vb.net wpf datagrid scrollviewer

10
推荐指数
2
解决办法
2005
查看次数

触摸屏平板电脑上的WPF Scrollviewer

我正在编写一个WPF应用程序,它将在完整的Windows 8触摸屏平板电脑(不是RT)上运行.

但是,触摸滚动似乎不起作用.所以我想知道这是我做错了什么,或者它是否可能?

所以,我有一个带滚动查看器的WPF窗口.在该滚动查看器中,我有一个StackPanel,其中包含大量文本块.见下文:

<ScrollViewer>
        <StackPanel>
            <TextBlock Text="Row 1" />
            <TextBlock Text="Row 2" />
            <TextBlock Text="Row 3" />
            <TextBlock Text="Row 4" />
            <TextBlock Text="Row 5" />
            <TextBlock Text="Row 6" />
            ....
            <TextBlock Text="Row 50" />                
        </StackPanel>
    </ScrollViewer>
Run Code Online (Sandbox Code Playgroud)

现在使用触摸屏我尝试滚动内容但它不移动.我只能使用侧面scollbar滚动内容,这不是我想要的方式.是否可以使用WPF进行触摸滚动?我也想对网格做同样的事情.

提前致谢.

我正在使用Visual Studio/Blend 2012.

wpf touchscreen scrollviewer windows-8

9
推荐指数
1
解决办法
1万
查看次数