GridViewComboBoxColumn Unselected Style

4 posts, 1 answers
  1. Michael
    Michael avatar
    3 posts
    Member since:
    Sep 2008

    Posted 27 Jul 2012 Link to this post

    The default GridViewComboBoxColumn in the RadGridView shows the cells like a TextBlock and it isn't until you set focus to the cell does it actually look like a RadComboBox.  Once the cell loses focus it goes back to looking like a TextBlock. We have a business need for the GridViewComboBoxColumn cells to always look like a RadComboBox for all the visible rows.  Is there an easy way to do this via styling?  We would like to avoid code behind.

  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 30 Jul 2012 Link to this post

    Hello,

     I would suggest you to check this forum thread where a similar topic is discussed.

    Kind regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. Michael
    Michael avatar
    3 posts
    Member since:
    Sep 2008

    Posted 31 Jul 2012 Link to this post

    We did do that already but we were concerned about performance when you had many rows of data (which we have).  I assume Telerik chose to not paint each combobox for this reason?  Is there a lighter weight way to style the cell so it just looks like a combobox until you click in it or perhaps an easy way to paint the cell when a single row is highlighted?
  4. Answer
    Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 02 Aug 2012 Link to this post

    Hi,

     This would not be a trivial task.

    If you have already exposed a property of the bound item holding the DisplayValue for the item selected in the combo, then you could define a CellTemplate painting the combobox style yourself. For example:

    <Border BorderBrush="#FF848484" CornerRadius="2" BorderThickness="1" HorizontalAlignment="Left" Height="25" Margin="160,136,0,0" VerticalAlignment="Top" Width="104">
    <Border BorderThickness="1" BorderBrush="White">
    <Border.Background>                           <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
    <GradientStop Color="White" Offset="0"/>
                                                                            <GradientStop Color="Gainsboro" Offset="0.5"/><GradientStop Color="#FFADADAD" Offset="0.5"/><GradientStop Color="#FFD4D4D4" Offset="1"/>                  </LinearGradientBrush>               </Border.Background>
    <Grid>
    <Grid.ColumnDefinitions>                  <ColumnDefinition/>                <ColumnDefinition Width="auto"/>
    </Grid.ColumnDefinitions>
    <TextBlock x:Name="DisplayMember" Margin="4,0" Text="{Binding DisplayedValue}"  VerticalAlignment="Center"/>
                                                    <Path Grid.Column="1" VerticalAlignment="Center"  Data="M0,0L1,0 2,0 3,0 4,0 5,0 5,1 4,1 4,2 3,2 3,3 2,3 2,2 1,2 1,1 0,1 0,0z" Fill="Black" HorizontalAlignment="Center" Height="3" Margin="3"  RenderTransformOrigin="0.5,0.5" Stretch="Fill"  Width="5">                      <Path.RenderTransform>                         <TransformGroup>                                          <ScaleTransform ScaleY="-1" ScaleX="1"/>                    <SkewTransform AngleY="0" AngleX="0"/>       <RotateTransform Angle="180"/>            <TranslateTransform X="0" Y="0"/>          </TransformGroup>                     </Path.RenderTransform>
    </Path>
    </Grid>
    </Border>
    </Border>

    Otherwise, you could use the approach already suggested. It will not degrade the performance compared to the performance of the GridViewComboBoxColumn itself. 

    Greetings,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top