or
<DataTemplate x:Key="ItemTemplate"> <Grid Width="350" Height="450"> <Grid.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="#FFFFFEA0" Offset="0"/> <GradientStop Color="#FFFFFE6A" Offset="0.567"/> </LinearGradientBrush> </Grid.Background> <TextBox Grid.Row="1" Text="{Binding Path=Content,Mode=TwoWay}" Background="Transparent"/> </Grid> </DataTemplate><telerik:RadGridView >
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header="{Binding Dag1}"
UniqueName="test1"
Style="{StaticResource KalenderDagColumnStyle}">
...public MainWindow()
{
InitializeComponent();
this.DataContext = this;
Dag1 = DateTime.Today;
Dag2 = DateTime.Today.AddDays(9);
}
public DateTime Dag1 { get; set; }
public DateTime Dag2 { get; set; }
The KalenderDagColumnStyle is a StyleSelector<local:DatumKolomStyleSelector x:Key="DatumKolomStyleSelector"
WeekdagStyle="{StaticResource WeekdagCellStyle}"
WeekendStyle="{StaticResource WeekendCellStyle}"
VandaagStyle="{StaticResource VandaagCellStyle}" />
<Style x:Key="KalenderDagColumnStyle"
TargetType="telerik:GridViewDataColumn">
<Setter Property="HeaderCellStyle"
Value="{StaticResource KalenderDagHeaderStyle}" />
<Setter Property="CellStyleSelector"
Value="{StaticResource DatumKolomStyleSelector}" />
</Style>
public class DatumKolomStyleSelector : StyleSelector
{
public Style VandaagStyle { get; set; }
public Style WeekendStyle { get; set; }
public Style WeekdagStyle { get; set; }
public override Style SelectStyle(object item, DependencyObject container)
{
GridViewCell c = container as GridViewCell;
DateTime d = (DateTime)c.Column.Header;
if (d == DateTime.Today)
return VandaagStyle;
else if (d.DayOfWeek == DayOfWeek.Saturday || d.DayOfWeek == DayOfWeek.Sunday)
return WeekendStyle;
else
return WeekdagStyle;
}
}
When a column represents Today, it has a style, when its a weekend day, it has a style, and otherwise it has another style
In Q2 c.Column.Header had a value in the SelectStyle method,
in Q3 c.Column.Header is null in the SelectStyle method .
When i hardcode the headers then the value is not null in the SelectStyle method,
but bound values are apparently not available in the style selector
Is this expected behaviour ? is there a way around for me ? ( using Tag instead of Header does not make a difference).
The column headers must be data-bound, because the user can scroll back and forwards in time.
I would have attached a sample solution to this thread; but apparently zips are not allowed
