0

顧客データを表示するデータグリッドがあります。一部の列にはコンボ ボックスがあります。行の検証エラーで、コンボ ボックスの背景を赤に変更したいと考えています。どうすればいいのですか?ROW ロード イベントで新しいデータ テンプレートを設定しようとしましたが、うまくいきませんでした。また、既存のテンプレートを変更しようとしましたが、封印されているため変更できないというエラーが表示されます。

Update1: ここにあるようなセッターも使用しようとしました http://www.telerik.com/community/forums/silverlight/gridview/rowloaded-event-to-change-font-style.aspx

まだ成果なし。

Update2: コード ビハインドでデータ テンプレートを設定しています。次のように

 Private Sub SetDataTemplate(e As GridViewAutoGeneratingColumnEventArgs, currentCompPropdefinition As ComponentPropertyDefinition)
    Dim celltemplate = Nothing
    If currentCompPropdefinition.Type = GetType(Boolean) OrElse currentCompPropdefinition.ValidValues IsNot Nothing Then
        If currentCompPropdefinition.Type = GetType(Boolean) Then
            celltemplate = New FrameworkElementFactory(GetType(CheckBox))
            celltemplate.SetBinding(CheckBox.IsCheckedProperty, New Binding(e.Column.Header))
        ElseIf currentCompPropdefinition.ValidValues IsNot Nothing AndAlso currentCompPropdefinition.ValidValues.Count <> 0 Then
            celltemplate = New FrameworkElementFactory(GetType(Telerik.Windows.Controls.RadComboBox))
            celltemplate.SetBinding(ItemsControl.ItemsSourceProperty, New Binding() With {.Source = currentCompPropdefinition.ValidValues})
            celltemplate.SetBinding(ComboBox.SelectedValueProperty, New Binding(e.Column.Header))
            celltemplate.SetValue(ComboBox.BackgroundProperty, FindResource("LightBG")) '(ComboBox.BackgroundProperty, )
        End If
        Dim dataTemplate As New DataTemplate() With {.VisualTree = celltemplate}

        dataTemplate.Seal()
        e.Column.CellTemplate = dataTemplate
    End If
End Sub
4

0 に答える 0