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

Q3 Grid - issue

1 Answer 40 Views
GridView
This is a migrated thread and some comments may be shown as answers.
stijn Ver Eecke
Top achievements
Rank 1
stijn Ver Eecke asked on 26 Nov 2010, 05:37 PM
Hi,

i moved to Q3 of telerik controls, and a piece of code, that worked great in Q2 broke down :
I have a grid, with predefined columns.
The column headers are bound to properties :
<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 { getset; }

        public DateTime Dag2 { getset; }

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 { getset; }
        public Style WeekendStyle { getset; }
        public Style WeekdagStyle { getset; }

        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

1 Answer, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 30 Nov 2010, 02:15 PM
Hello stijn Ver Eecke,

You can attached only images in the forum posts.

I suppose the header binding happens after the select style is executed.
What you can try is to access the Dag1 and Dag2 properties directly, not through the e.Column.Header property.

Hope this is feasible for you.



Regards,
Veselin Vasilev
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
Tags
GridView
Asked by
stijn Ver Eecke
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or