I've followed the example at:
http://docs.telerik.com/devtools/wpf/controls/radgridview/troubleshooting/styling-custom-header.html
Well, it works for most cases, but it doesn't work if the column visibility is bound to a property, and it is invisible when the grid is loaded. It's hard for me to give a simple example that demonstrates exactly the scenario I have, but I've managed to find a different scenario, which reproduces the problem.
MyGridView.xaml
<
UserControl
x:Class
=
"GridViewHeaderForground.MyGridView"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
xmlns:local
=
"clr-namespace:GridViewHeaderForground"
mc:Ignorable
=
"d"
d:DesignHeight
=
"300"
d:DesignWidth
=
"300"
>
<
Grid
>
<
telerik:RadGridView
AutoGenerateColumns
=
"False"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
>
<
telerik:GridViewDataColumn.Header
>
<
TextBlock
Text
=
"First Column"
Foreground
=
"{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type ContentControl}}}"
/>
</
telerik:GridViewDataColumn.Header
>
</
telerik:GridViewDataColumn
>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
</
Grid
>
</
UserControl
>
MainWindow.xaml
<
Window
x:Class
=
"GridViewHeaderForground.MainWindow"
xmlns:local
=
"clr-namespace:GridViewHeaderForground"
Title
=
"MainWindow"
Height
=
"350"
Width
=
"525"
>
<
Grid
>
<
TabControl
SelectedIndex
=
"0"
>
<
TabItem
Header
=
"1"
>
<
local:MyGridView
/>
</
TabItem
>
<
TabItem
Header
=
"2"
>
<
local:MyGridView
/>
</
TabItem
>
</
TabControl
>
</
Grid
>
</
Window
>
As you can see, the first tab looks fine, but if you switch to the second one, then the textblocks are all black.
If you try to "debug" it with snoop, and it fixes the binding problem.
My scenario is a little different: I have several RadPanes which only one of them is selected. On the other ones, few columns are invisible by using the IsVisible which is bound to a property.
When one of the RadPanes get selected, it loads (and so does the header cells). On the RowLoaded event, I get only the cells that are visible (if I'm correct).
Now if I change that property to true, the column becomes visible, but the textblock is black.
I think both problems are the same.
How do I solve it? I need to have both image and text in the header.
Thanks.