XAML ListView进入ScrollView不会滚动

时间:2018-07-12 18:59:47

标签: wpf xaml

我有一些对象(以编程方式添加)全部是存储在ScrollViewer中的Grid的子对象

<UserControl x:Class="MyNS.Recursos.Controles.Controls.Esquemas.SchemaContainerControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:MyNS.Recursos.Controles.Controls.Esquemas"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800"
             x:Name="ThisSchemaContainerControl">
    <Grid>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <TextBlock Text="{Binding ElementName=ThisSchemaContainerControl,Path=SchemaToShow.Titulo}" Style="{DynamicResource BlockHeaderWarning}"/>
            <ScrollViewer Grid.Row="1">
                <Grid x:Name="SchemaMainGrid">

                </Grid>
            </ScrollViewer>
        </Grid>
    </Grid>
</UserControl>

我有这个自定义控件

<local:SchemaControlBase x:Class="MyNS.Recursos.Controles.Controls.Esquemas.SchemaCie10"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:MyNS.Recursos.Controles.Controls.Esquemas"
             xmlns:ctr="clr-namespace:ParadigmaN.Recursos.Controles.Controls"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800"
             x:Name="ThisSchemaCie10">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <TextBlock Text="{Binding ElementName=ThisSchemaCie10,Path=Title,FallbackValue=Item-Title}" Style="{DynamicResource SchemaItemTitleStyle}"/>
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="10*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <ctr:Search 
                SearchParms="{Binding ElementName=ThisSchemaCie10,Path=BusqCie10}" 
                SelectedItem="{Binding ElementName=ThisSchemaCie10,Path=Cie10,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}"/>
            <ComboBox 
                ItemsSource="{Binding ElementName=ThisSchemaCie10,Path=TiposDiagnostico}"
                DisplayMemberPath="Descripcion"
                SelectedItem="{Binding ElementName=ThisSchemaCie10,Path=TipoDiagnosticoSeeleccionado,UpdateSourceTrigger=PropertyChanged}"
                Grid.Column="1"/>
            <Button
                Margin="7,0,7,0"
                Command="{Binding ElementName=ThisSchemaCie10,Path=AddCommand}"
                Style="{DynamicResource InLineAddButton}"
                Grid.Column="2"/>
        </Grid>
        <ListView
            Grid.Row="2"
            ItemsSource="{Binding ElementName=ThisSchemaCie10,Path=Diagnosticos}"
            HorizontalContentAlignment="Stretch"
            SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="1*"/>
                            <ColumnDefinition Width="10*"/>
                            <ColumnDefinition Width="2.5*"/>
                        </Grid.ColumnDefinitions>
                        <Button
                            Margin="5,0,10,0"
                            Style="{DynamicResource InLineDeleteButton}"
                            Command="{Binding ElementName=ThisSchemaCie10,Path=DeleteCommand}"
                            CommandParameter="{Binding }"/>
                        <TextBlock Text="{Binding CodigoCie10}" Grid.Column="1"/>
                        <TextBlock Text="{Binding Descripcion}" Grid.Column="2"/>
                        <TextBlock Text="{Binding DescripcionTipo}" Grid.Column="3"/>
                    </Grid>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </Grid>
</local:SchemaControlBase>

它绘制一个列表视图。但是当我用鼠标在项目列表上滚动时,滚动停止工作。

我做错了什么?

为什么不像其他元素(TextBox,TextBlock,CheckBox等)那样接受滚动事件?

0 个答案:

没有答案