This is a migrated thread and some comments may be shown as answers.
Bindings in GridViewDataColumn.Header does not get evaluated
2 Answers 53 Views
This is a migrated thread and some comments may be shown as answers.
Marius
Top achievements
Rank 1
Marius asked on 15 Dec 2010, 12:16 PM
I am binding from a column header to some properties on a viewmodel. This binding is set up as shown:

                <telerik:GridViewDataColumn>
                    <telerik:GridViewDataColumn.Header>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <Label Grid.Row="0">Volume flow</Label>
                            <ComboBox Style="{StaticResource unitGridHeader}" Grid.Row="1" ItemsSource="{Binding Path=UnitVolumeFlow.AvailableUnits}"
                                          SelectedItem="{Binding Path=UnitVolumeFlow.CurrentUnit}" />
                        </Grid>
                    </telerik:GridViewDataColumn.Header>

The header is not populated with data when its shown, I also notice that there is no binding error output from Visual Studio. I've done a little research and I see that the DataContext from the grid is propagated to the DataGridViewColumn.DataContext. It seems like that binding evaluation is ignored entirely. What can cause this behaviour and how can I fix it?

2 Answers, 1 is accepted

Sort by
0
Marius
Top achievements
Rank 1
answered on 15 Dec 2010, 01:03 PM
Got it! The DataContext was not propagated from the GridViewDataColumn to the header. I added a "Loaded" event to the root element in the header and copied the DataContext:

        private void Header_Load(object sender, RoutedEventArgs e)
        {
            FrameworkElement element = sender as FrameworkElement;
            element.DataContext = DataContext;
        }
0
Carsten Jendro
Top achievements
Rank 2
answered on 17 Jul 2011, 04:24 AM
I had the same problem, is this already reported as a bug?
Asked by
Marius
Top achievements
Rank 1
Answers by
Marius
Top achievements
Rank 1
Carsten Jendro
Top achievements
Rank 2
Share this question
or