2014-04-23 74 views
0

我想知道是否有可能在XAML中創建一個case或一個if語句或某種觸發器?我的目標是創建名稱爲ID 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,因爲它對我的雙擊動作起到了推動作用。

回答

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> 

UPDATE

它可以是類似這樣

<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> 
+0

你能給我使用常規控制控制?我會找到其餘的請。 – Master

+0

@ user3276954更新了我的答案。 –

+0

這不會很有效,因爲查詢非常動態。我無法指定標題,因爲它們不同於查詢 – Master