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

Style in GridViewDataColumn with IValueConverter

7 Answers 162 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 17 Jan 2013, 05:47 PM
Hello,
When using a RadGrid styled with Theme="Expression_Dark" and a GridViewDataColumn with Binding with IValueConverter that simply converts a bool to a text string (of Yes or No) it seems the color of the text is black, not white as the other cells without IValueConverters. See attached capture. This makes it difficult to read.

This consistently happens with two of our grids styled with "Expression_Dark", this occurs with or without our ApplicationTheme set as StyleManager.ApplicationTheme = new Expression_DarkTheme();

On a related note when our ApplicationTheme is set as Expression_DarkTheme our grid styled with Office_Black seem to inherit the Expression_DarkTheme when cells are in edit mode.

Is their a fix or workaround for this?
Can the column/cell theme be forced for edit and display?

Thank you.

7 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 22 Jan 2013, 05:47 PM
Hi Patrick,

As it turns out, I was able to reproduce this problem. Unfortunately, I will need a little bit more time to further investigate the case. I will contact you back soon.

As for a workaround, you can try this:

<telerik:GridViewDataColumn   Header="Is Active">
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding IsActive, Converter={StaticResource MyBoolConverter}}" Foreground="Red"/>
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>

Kind regards,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Patrick
Top achievements
Rank 1
answered on 01 Feb 2013, 02:57 PM
Hello Yoan,
Thanks for the quick response. Is there any update on this? Since you can reproduce it, can we expect it to be addressed in a future release?

Thanks.
0
Maya
Telerik team
answered on 05 Feb 2013, 09:33 AM
Hello Patrick,

Actually, this is not an issue of RadGridView. What happens is that the ContentControl (that is created when changing the Boolean type to string) does not create a TextBlock when it receives string as content. This behavior is not true for WPF. And since we do not know what is inside ContentControl, we do not have any style prepared for it. What we have is theme for a TextBlock, but since the element in the cell in this case is not a TextBlock, it is not styled.
You can prove that behavior by creating a simple implicit style targeting TextBlock and verify that it is not applied in the elements of the column.
The suggestion provided above is the most appropriate one for handling this scenario.
Let me know in case you have any other problems with the implementation.  

All the best,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Patrick
Top achievements
Rank 1
answered on 08 Mar 2013, 12:25 PM
Maya,

The above suggestion is sufficient
 for the boolean conversion. What about when our ApplicationTheme is set as Expression_DarkTheme the grid styled with Office_Black seems to inherit the Expression_DarkTheme when cells are in edit mode?

See attached. Is there a way I'm missing to implicitly inherit the grids' theme instead of the application theme when in edit mode?

An example of our EditTemplate is as follows:
<telerik:GridViewDataColumn.CellEditTemplate>
    <DataTemplate>
        <CheckBox VerticalAlignment="Center" Margin="5,0,5,0" IsChecked="{Binding IsDefault, Mode=TwoWay}" />
    </DataTemplate>
</telerik:GridViewDataColumn.CellEditTemplate>

Thank you,
Patrick
0
Maya
Telerik team
answered on 13 Mar 2013, 03:37 PM
Hi Partick,

We will investigate the case to verify whether this behavior can be improved. In the meantime, will it be possible to clarify why do you set an application theme as you want the one for the grid to be different ?  

Kind regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Patrick
Top achievements
Rank 1
answered on 28 Mar 2013, 04:37 PM
We set the application theme because it is a convenient way to implicitly style many of the telerik controls we use. Correct me if I'm wrong, but I thought that was the point of an application theme. Much of our UI makes heavy use of telerik controls and explicitly styling Expression_Dark on 200+ buttons, docks, windows, etc seems unnecessary. Especially if we want to alter the overall look it would be in one place (app theme), instead of checking out and changing hundreds of files for our solution.

We have a few rare instances when we would like to use a different style, so explicitly setting those few makes sense. The RadGridView as Expression_Dark is too dark for our UI, so Office_Black fits the bill nicely. It is inconvenient that the Edit and Display mode of the cells inherit from the application theme instead of the parent RadGrid.

This same issue arose using a GridViewCheckBoxColumn on a RadGridView. Grid was styled Office_Black, the checkbox is styled Expression_Dark (app theme) in both it's Display and Edit modes, which looked bad enough that it was logged as a bug to us developers, which forced us to forgo using, what would be perfectly appropriate, a GridViewCheckBoxColumn in favor of manually adding an explicitly styled checkbox in a custom cell template for a regular GridViewColumn, which dropped some of the nice functionality you've placed in the GridViewCheckBoxColumn.

It would be nice if internal controls inherited the styles from their parents, or even better the ability to specify if you wanted a different theme. Does this make sense?

Thank you,
Patrick


0
Maya
Telerik team
answered on 02 Apr 2013, 03:21 PM
Hi Patrick,

Indeed, you are totally right. I am investigating the issue to verify why some elements do no take the theme from their parent (RadGridView in this case).
I will let you know once I have more information.
Thank you for your patience. 

Kind regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Patrick
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Patrick
Top achievements
Rank 1
Maya
Telerik team
Share this question
or