2015-10-08 119 views
-1

我想隱藏兩個檢查框中的colomn,我使用telerk radgrid控件。網格包含五個colomn ID,FName參數,LName的,MobileNo,分支。當複選框上要隱藏ID和姓名colomn請給暗示了,我的代碼如下檢查點擊複選框隱藏多行

C#代碼: 類MainWindowViewModel {

public MainWindowViewModel() 
    { 
     EmpList = ListOfEmpInfo(); 
    } 

    private ObservableCollection<EmpInfo> ListOfEmpInfo() 
    { 
     return new ObservableCollection<EmpInfo>() 
     { 
      new EmpInfo(){ ID=1, City ="Pune" , FirstName ="Rahul" , LasttName ="Rathod", MobileNumber =123}, 
      new EmpInfo(){ ID=2, City ="Mumbai" , FirstName ="Mahesh" , LasttName ="Yogaa", MobileNumber =456}, 
      new EmpInfo(){ID=3, City ="Jalna" , FirstName ="Ganesh" , LasttName ="Kapadia", MobileNumber =178923} 



     }; 





    } 
    public ObservableCollection<EmpInfo> EmpList 
    { 
     get; 
     set; 
    } 


} 

<Grid Background="White"> 
     <Grid.ColumnDefinitions> 
      <ColumnDefinition Width="150"/> 
      <ColumnDefinition Width="500"/> 
      <ColumnDefinition Width="40"/> 
     </Grid.ColumnDefinitions> 
     <CheckBox Content="Hide Show" IsChecked="{Binding IsVisible}" Height="40" Grid.Column="2"></CheckBox> 
       <telerik:RadGridView x:Name="radGridView" ItemsSource="{Binding EmpList}" 
         Grid.Column="1" 
         Margin="10,0,0,0" /> 

    </Grid> 
+0

你嘗試過什麼來實現你的目標是什麼?你到底有什麼問題? – mittmemo

+0

檢查複選框時,我想隱藏radgridview的ID和名稱colomns –

+0

我明白你想要做什麼。你有什麼嘗試? – mittmemo

回答

1

這裏你可以看到一個有效的解決方案:WPF Control TabItem visibility from a checkbox

當然,你的情況,你將需要用X來命名複選框:名稱,並使用它,像這樣:

<ColumnDefinition Width="150" Visibility="{Binding IsChecked,ElementName=chk,Converter={StaticResource b2v}}"/> 

萬一其他鏈接不可用,這裏是靜態資源:

<Window.Resources> 
    <BooleanToVisibilityConverter x:Key="b2v" /> 
</Window.Resources>