禁用某些网格列

时间:2014-04-23 20:04:35

标签: xaml

我想知道是否有可能在XAML中创建一个case或if语句或某种触发器?我的目标是使列名称为Isvisible = false的列标题。我的列是自动生成的,这使得它更加困难。如果我能帮助您了解色谱柱的可见性,请

<telerik:RadGridView ItemsSource="{Binding AllQueries, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" AutoGenerateColumns="True">
</telerik:RadGridView>

AllQueries非常动态,列根据某些操作而变化,但这是一个示例。

AllQueries = (from z in ctx.Projects
              join y in ctx.ProjectScopes on z.ProjectScope_Id equals y.Id
              where (z.StartDate <= StartDateTo && z.EndDate >= EndDateTo && y.Value == "Community Development")
              select new {Id = z.Id, z.Created, z.EndDate, z.ProjectName }).ToList();

我想显示Created,EndDate和ProjectName。我无法删除ID,因为它会在我的双击动作上播放。

1 个答案:

答案 0 :(得分:0)

您必须在列模板内的XAML中明确设置以禁用某个Column

<telerik:RadGridView ItemsSource="{Binding AllQueries, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" AutoGenerateColumns="True">
 <!-- GridView's Column Template 
    <telerik:Column IsEnabled="False"> -- I'm not sure what is the exact control name for `Telerik's RadGridView Column` and if it requires setting binding to know what field it will map in the column.
   -->
</telerik:RadGridView>

<强>更新

它可以与此类似

<DataGrid Name="dealerList" AutoGenerateColumns="False" ItemsSource="{Binding DealerList}">
  <DataGrid.Columns>
     <DataGridTextColumn Header="ID" Width="30"  Binding="{DealerId}" IsEnabled="False" />                        
     <DataGridTextColumn Header="Name" Width="*" Binding="{DealerName}" />                       
  </DataGrid.Columns>
</DataGrid>