This is a migrated thread and some comments may be shown as answers.

GridView background color change when combobox is changed.

4 Answers 261 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Hyunho
Top achievements
Rank 1
Hyunho asked on 24 Apr 2013, 11:23 AM
Hello sir,

I found something strange when I use RadGridView.
I'm using GridViewDataColumn and RadComboBox for my grid. and I also use CellStyle to enble/disble columns.

My code is as below.


<telerik:RadWindow x:Class="NetworkDesignTool.CameraSettingsPane"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                xmlns:primitives="clr-namespace:Telerik.Windows.Controls.Diagrams.Primitives;assembly=Telerik.Windows.Controls.Diagrams"
                xmlns:local="clr-namespace:NetworkDesignTool"
                Header="Video setup"
                ResizeMode="CanMinimize"
                WindowStartupLocation="CenterScreen"   
                Height="350" Width="600">
 
    <telerik:RadWindow.Resources>
        <Style x:Key="GridViewCellStyle" TargetType="telerik:GridViewCell" />
        <Style x:Key="OneClickComboBox" TargetType="telerik:RadComboBox">
            <Setter Property="OpenDropDownOnFocus" Value="True"/>
        </Style>
 
        <Style x:Key="disabledStyle" TargetType="telerik:GridViewCell">
            <Setter Property="IsEnabled" Value="{Binding IsActive, Mode=TwoWay}"/>
        </Style>
         
    </telerik:RadWindow.Resources>
     
     
    <Grid>
        <telerik:RadGridView RowIndicatorVisibility="Collapsed"
                             ShowGroupPanel="False"
                             AutoGenerateColumns="False"
                             CanUserFreezeColumns="False"
                             IsFilteringAllowed="False"
                             ItemsSource="{Binding VideoProfiles}">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding ID}"
                                            Header="ID" IsSortable="False" IsReadOnly="True"/>
 
                <telerik:GridViewDataColumn DataMemberBinding="{Binding IsActive}"
                                            Header="Use"
                                            IsReadOnly="True">
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox IsChecked="{Binding IsActive, Mode=TwoWay}"/>
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
                 
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"
                                            Width="150"
                                            Header="Profile Name" IsSortable="False"
                                            CellStyle="{StaticResource disabledStyle}"
                                            />
 
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Codec, Mode=TwoWay}"
                                            Width="*"
                                            IsReadOnly="True"
                                            Header="Codec" IsSortable="False">
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <telerik:RadComboBox SelectedValuePath="Codec"
                                                 SelectedValue="{Binding Codec}"
                                                 ItemsSource="{Binding CodecsRange}"
                                                 IsEnabled="{Binding IsActive, Mode=TwoWay}"
                                                 DisplayMemberPath="Name" />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
 
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Resolution, Mode=TwoWay}"
                                            Width="*"
                                            IsReadOnly="True"
                                            Header="Resolution" IsSortable="False">
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <telerik:RadComboBox SelectedValuePath="Resolution"
                                                 SelectedValue="{Binding Resolution}"
                                                 ItemsSource="{Binding ResolutionsRange}"
                                                 IsEnabled="{Binding IsActive, Mode=TwoWay}"
                                                 DisplayMemberPath="Name" />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
 
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Framerate, Mode=TwoWay}"
                                            Width="*"
                                            IsReadOnly="True"
                                            Header="Framerate" IsSortable="False">
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <telerik:RadComboBox SelectedValuePath="Framerate"
                                                 SelectedValue="{Binding Framerate}"
                                                 ItemsSource="{Binding FrameratesRange}"
                                                 IsEnabled="{Binding IsActive, Mode=TwoWay}"
                                                 DisplayMemberPath="Name" />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
 
 
 
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
 
    </Grid>
</telerik:RadWindow>


And I am attaching a picture about this one.

4 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 25 Apr 2013, 08:14 AM
Hello,

I am not sure if you would like to change the Background for the GridView (as the title says) or for the Cells in the first column, would you please clarify your scenario? 
 

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Hyunho
Top achievements
Rank 1
answered on 26 Apr 2013, 12:46 AM
Hello Didie,

The problem is that background color of a row is changed when I clicked ComboBox in a cell.

I never set background color as red, but when I changed a value of cell in a row, It's background color is changed as red color.
(You can see it the attached file of previous message)
The color should not be changed.

Thank you.
0
Accepted
Dimitrina
Telerik team
answered on 26 Apr 2013, 10:49 AM
Hello,

This red background shows that the row in not valid because of the value you have selected from the last ComboBox. If you do not want to have indication for the error, then you can set the ValidateOnDataErrors property of the RadGridView to "None".

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Hyunho
Top achievements
Rank 1
answered on 29 Apr 2013, 10:55 PM
Hello Didie,
Now it works well, thank you for your help.
Tags
GridView
Asked by
Hyunho
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Hyunho
Top achievements
Rank 1
Share this question
or