GridView background color change when combobox is changed.

5 posts, 1 answers
  1. Hyunho
    Hyunho avatar
    23 posts
    Member since:
    Feb 2013

    Posted 24 Apr 2013 Link to this post

    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.
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 25 Apr 2013 Link to this post

    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.

  3. Hyunho
    Hyunho avatar
    23 posts
    Member since:
    Feb 2013

    Posted 25 Apr 2013 Link to this post

    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.
  4. Answer
    Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 26 Apr 2013 Link to this post

    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.

  5. Hyunho
    Hyunho avatar
    23 posts
    Member since:
    Feb 2013

    Posted 29 Apr 2013 Link to this post

    Hello Didie,
    Now it works well, thank you for your help.
Back to Top