【问题标题】:How hide column whit DataGridTextColumn in UWP [XAML]?如何在 UWP [XAML] 中隐藏带有 DataGridTextColumn 的列?
【发布时间】:2019-02-06 15:15:31
【问题描述】:

我在 UWP 的一个项目的页面中有一个 DataGridTextColumn,使用这个页面的代码。由于 UWP 没有本机 DataGrid,因此调查并发现此代码已打开:

https://github.com/RSuter/MyToolkit/wiki/DataGrid

目前我是这样的:

xmlns: controls = "using: MyToolkit.Controls"

<controls: DataGrid x: Name = "DataGrid" ItemsSource = "{Binding Third Parties}" SelectedItem = "{Binding ThirdSelected, Mode = TwoWay}" DefaultOrderIndex = "0" SelectionMode = "Extended">
    <controls: DataGrid.Columns>
         <controls: DataGridTextColumn Width = "150" Header = "Nit" Binding = "{Binding Nit}" />
         <controls: DataGridTextColumn Width = "300" Header = "Nom1" Binding = "{Binding Nom1}" />
         <controls: DataGridTextColumn Width = "300" Header = "Ape1" Binding = "{Binding Ape1}" />
         <controls: DataGridTextColumn Width = "300" Header = "Name" Binding = "{Binding Name}" />
         <controls: DataGridTextColumn Width = "300" Header = "Tel" Binding = "{Binding Tel}" />
     </controls:DataGrid.Columns>         
</controls: DataGrid>

我有几个名为“Person”的模型的列,当我进行查询时它加载得很好,但我希望使用该程序的用户选择他想要查看的列。

为此,我想到对列使用 Visibility 或 IsEnable 的某些属性,但事实证明它没有。我该怎么做?

【问题讨论】:

    标签: xaml uwp datagrid controls


    【解决方案1】:

    由于 UWP 没有原生 DataGrid,...

    Windows Community Toolkit 包含一个DataGrid 控件,其列具有IsVisible 属性,您可以像往常一样将其设置为true/false

    你可以通过安装this NuGet package在你的UWP 10.0.15063.0+应用中使用它。

    【讨论】:

    • 好的,我正在安装 NuGet 包...现在如何调用“IsVisible”属性?
    • 只需设置列的属性,例如:&lt;controls:DataGridTextColumn IsVisible="True" .../&gt;
    猜你喜欢
    • 1970-01-01
    • 2021-02-09
    • 2019-01-19
    • 1970-01-01
    • 2015-08-17
    • 2016-05-29
    • 2016-10-25
    • 1970-01-01
    • 2019-06-13
    相关资源
    最近更新 更多