当前位置:首页 > wpf DataGrid 隐藏行的方法

wpf DataGrid 隐藏行的方法

点击次数:8123  更新日期:2018-07-24

wpf中DataGrid 隐藏某一行的方法:

<DataGrid Grid.Row="1" x:Name="dataGridTable" IsReadOnly="True" AlternationCount="2" AutoGenerateColumns="False" SelectionMode="Extended" HorizontalAlignment="Left" VerticalAlignment="Top" >

            <DataGrid.ItemContainerStyle>

                <Style TargetType="DataGridRow">

                    <Setter Property="Visibility" Value="{Binding Visible}"/>

                </Style>

            </DataGrid.ItemContainerStyle>


后台

//rows 为 ObservableCollection<ExpandoObject>

dynamic selected = rows.First(r => ((dynamic)r).GUID == guid);

selected.Visible=Visibility.Collapsed;