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

[Solved] Force GridViewDataColumn Foreground

2 Answers 314 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
FaRess
Top achievements
Rank 1
FaRess asked on 10 Aug 2011, 12:33 PM
Hello,

In our application there is some styles that are injected at runtime, like the implicit style for textblock.

The problem is the GridViewDataColumn is also affected by that implicit style that targets textblock.

I've played around with different styles on that control without success, I would like to force the foreground of the GridViewDataColumn to be White for example or to not get affected by the implicit style of texblock.

Thank you

2 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 10 Aug 2011, 12:54 PM
Hi Faress,

 
Indeed you are quite right! An implicit style targeted at a TextBlock element will affect all text elements in RadGridView. If you have defined an implicit style targeted at a TextBlock and you do not need it only in RadGridView throughout your application you should ignore this style at a RadGridView level. This can be achieved through defining an emplicit style targeted at a TextBlock element within RadGridView's Resource Collection:


<UserControl.Resources>
        <Style TargetType="TextBlock">
            <Setter Property="Foreground" Value="Green"/>
        </Style>
    </UserControl.Resources>
 
    <Grid x:Name="LayoutRoot" Background="White" DataContext="{Binding Source={StaticResource SampleDataSource}}">
        <telerik:RadGridView x:Name="grid"  AutoGenerateColumns="True" ItemsSource="{Binding Collection}">
            <telerik:RadGridView.Resources>
                <Style TargetType="TextBlock"/>
                </telerik:RadGridView.Resources>
    </telerik:RadGridView>
    </Grid>



Regards,
Vanya Pavlova
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
FaRess
Top achievements
Rank 1
answered on 10 Aug 2011, 01:49 PM
Thank you Vanya, this solution works, the problem is I would have to do that on every single GridView in the application, I'm trying to find a way to define that ressource in an implicit style for GridView but doesn"t seems to work, do you know how can I do so the solution you gave me works everywhere ?
Tags
GridView
Asked by
FaRess
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
FaRess
Top achievements
Rank 1
Share this question
or