【问题标题】:Datagrid - ItemsPresenter - vertical ScrollviewerDatagrid - ItemsPresenter - 垂直滚动查看器
【发布时间】:2018-04-22 07:00:45
【问题描述】:

您好 Stackoverflow 成员,

我是新来的!对不起,一个简短的问题。但我需要你的帮助! 我有一个 2000 行的 Datagrid。 (按 CustomerNbr 分组)

vb.net
昏暗分组为新 ListCollectionView(full_list)
grouped.GroupDescriptions.Add(New PropertyGroupDescription("CustNbr"))
Datagrid.ItemsSource = 分组

这段代码运行良好

<DataGrid.GroupStyle>
    <GroupStyle>
        <GroupStyle.HeaderTemplate>
            <DataTemplate>
                <StackPanel>
                    <TextBlock Text="{Binding Path=Name}" />
                </StackPanel>
            </DataTemplate>
        </GroupStyle.HeaderTemplate>
        <GroupStyle.ContainerStyle>
            <Style TargetType="{x:Type GroupItem}">
                <Setter Property="Template" >
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type GroupItem}">
                            <Expander MaxHeight="400" FontWeight="Bold" Background="{Binding Path=Items, Converter={StaticResource convert_Backcolor}}" >
                                <Expander.Header>
                                    <StackPanel Orientation="Horizontal" >
                                        <TextBlock Text="{Binding Path=Name}" Margin="10,0,10,0" />
                                        <TextBlock Text="{Binding Path=Items, Converter={StaticResource convert_Cust_Name}}" MinWidth="300" Margin="10,0,10,0" />
                                        <TextBlock Text="{Binding Path=Items, Converter={StaticResource convert_Summe},ConverterCulture=de-DE, StringFormat={}{0:n2}}" HorizontalAlignment="Right" Margin="40,0,0,0" />
                                    </StackPanel>
                            </Expander.Header>
                                <ItemsPresenter />
                        </Expander>
                    </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </GroupStyle.ContainerStyle>
    </GroupStyle>
</DataGrid.GroupStyle>

但是当我在 ItemsPresenter 添加滚动查看器时,我得到一个错误:

<ScrollViewer>  
    <ItemsPresenter />  
</ScrollViewer>

错误来了,当我做第二个分组的 custnbr screen

错误:invalidOperationExeption 未处理

我需要 ScrollViewer,因为我在 CustNbr 上有很多发票。问题出在扩展器中。在 Expander.Content 中,不支持垂直 ScrollViewer 之类的......

谁能帮帮我?

【问题讨论】:

    标签: wpf vb.net xaml datagrid itemspresenter


    【解决方案1】:

    解决方案:在 Datagrid Header 中不允许使用以下语句:CanUserAddRows="False" CanUserDeleteRows="False" IsReadOnly="True"

    另见此处: https://blogs.msdn.microsoft.com/vinsibal/2008/10/01/overview-of-the-editing-features-in-the-wpf-datagrid/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-09-08
      • 2017-04-13
      • 2018-12-16
      • 2021-04-05
      • 1970-01-01
      • 1970-01-01
      • 2012-03-16
      相关资源
      最近更新 更多