2013-07-22 27 views
0

我有一列RadGridView(Telerik的版本GridView),並在此RadGridView我有以下的列:WPF GridView控件SetReadOnly或啓用基於一個複選框

<telerik:GridViewCheckBoxColumn DataMemberBinding="{Binding Revoked}" AutoSelectOnEdit="True" Header="Revoked" UniqueName="Revoked" Width="Auto" IsReadOnly="False" FooterTextAlignment="Right" CellStyle="{StaticResource GridCellStyle}" /> 

我想要麼啓用/禁用或者根據複選框列設置網格中另外兩列的只讀標誌。

<telerik:GridViewDataColumn 
    DataMemberBinding="{Binding RevokedBy}" 
    Header="Revoked By" 
    UniqueName="RevokedBy" 
    Width="Auto" 
    IsReadOnly="{Binding Revoked}" 
    FooterTextAlignment="Right" 
    CellStyle="{StaticResource GridCellStyle}" /> 
<telerik:GridViewDataColumn 
    DataMemberBinding="{Binding RevokedDateTime}" 
    DataFormatString="dd/MM/yyyy HH:mm:ss" 
    Header="Revoked Date Time" 
    UniqueName="RevokedDateTime" 
    Width="Auto" 
    IsReadOnly="{Binding Revoked}" 
    FooterTextAlignment="Right" 
    CellStyle="{StaticResource GridCellStyle}"> 
    <telerik:GridViewDataColumn.CellEditTemplate> 
     <DataTemplate> 
      <WrapPanel Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="4"> 
       <telerik:RadDateTimePicker 
        Margin="0 5 5 5" 
        Width="250" 
        DisplayFormat="Short"          
        InputMode="DatePicker" 
        DateSelectionMode="Day" 
        DateTimeWatermarkContent="Select Date" 
        MaxWidth="155" 
        MinWidth="155" 
        SelectedDate="{Binding RevokedDate, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/> 

       <telerik:RadMaskedDateTimeInput 
        Margin="5" 
        Culture="en-GB" 
        EmptyContent="Enter Time" 
        InputBehavior="Replace" 
        Mask="HH:mm:ss" 
        SelectionOnFocus="SelectAll" 
        TextMode="MaskedText" 
        Value="{Binding RevokedTime, Mode=TwoWay}"/> 
      </WrapPanel> 
     </DataTemplate> 
    </telerik:GridViewDataColumn.CellEditTemplate> 
</telerik:GridViewDataColumn> 

到目前爲止,我已經嘗試結合IsReadOnlyIsEnabled財產Revoked但是這似乎並沒有工作,我可以看到Revoked屬性被設置和RaisePropertyChanged事件再次發生。

任何幫助將不勝感激。

更新:

視圖模型:

/// <summary> 
/// The agreements. 
/// </summary> 
private ObservableCollection<NotificationAgreement> agreements; 

/// <summary> 
/// Gets or sets the agreements. 
/// </summary> 
public ObservableCollection<NotificationAgreement> Agreements 
{ 
    get 
    { 
     return this.agreements ?? (this.agreements = new ObservableCollection<NotificationAgreement>()); 
    } 

    set 
    { 
     this.agreements = value; 
     this.RaisePropertyChanged(() => this.Agreements); 
    } 
} 

而且NotificationAgreement類具有以下屬性。

/// <summary> 
/// Gets or sets a value indicating whether revoked. 
/// </summary> 
public bool Revoked 
{ 
    get 
    { 
     return this.revoked; 
    } 

    set 
    { 
     this.revoked = value; 
     this.RaisePropertyChanged(() => this.Revoked); 
    } 
} 

回答

0

你可以粘貼你的ViewModel,我只是想知道你正在提出通知,以查看何時撤銷被更改。

(1)您的視圖模型應該有一個ObservableCollection<yourObject>

(2)yourObject應該實現INotifyPropertyChanged

(3)你的對象應以下列方式擁有財產性

private bool _revoked; 

public bool Revoked 
{ 
    get{return _revoked;} 
    set { _revoked=value; 
     RaisPropertyChanged("Revoked"); 
} 

這只是模擬代碼,請用你的方式做。

+0

根據要求更新我的問題 –

相關問題