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

Bound Column Headers

3 Answers 129 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Koren
Top achievements
Rank 1
Koren asked on 26 Jul 2013, 09:33 PM
I need to use the datacontext of my gridview (or window) to bind my column headers.  I tried both the gridview and window relativesource and got the same results.  My initial view of the grid looks great - any of the columns that are displayed on the initial view have the correct headers.  However, if you scroll to the right, any of the columns that weren't originally displayed don't have a header (the datacontext has the correct labels - I've checked).  I made the window wider which meant that more column headers display but still not all.  Is there some trick to getting all the column headers to bind?

I have attached pictures of the left and right side of the grid.

Here is an example of one of the data columns.  Note: The values are displayed correct.

<telerik:GridViewDataColumn ColumnGroupName="ColumnsTrans" DataMemberBinding="{Binding Value1}" DataFormatString="{}{0:f2}" IsFilterable="False" IsReadOnly="True" Width="70" FooterTextAlignment="Right" >
                            <telerik:GridViewDataColumn.Header>
                                <TextBlock TextWrapping="Wrap" TextAlignment="Center">
                                    <TextBlock.Text>
                                        <Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type Window}}" Path="DataContext.Label1" />
                                    </TextBlock.Text>
                                </TextBlock>
                            </telerik:GridViewDataColumn.Header>
                            <telerik:GridViewDataColumn.AggregateFunctions>
                                <telerik:SumFunction Caption="" ResultFormatString="{}{0:N2}" ></telerik:SumFunction>
                            </telerik:GridViewDataColumn.AggregateFunctions>
                        </telerik:GridViewDataColumn>

3 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 31 Jul 2013, 04:27 PM
Hi,

Firstly, could you verify whether you get any binding errors in your output window ? You can try to define the DataContext for the "Label1" as a StaticResource and then set the binding for the TextBlock specifying the valid Source. 



Regards,
Yoan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Koren
Top achievements
Rank 1
answered on 31 Jul 2013, 05:00 PM
I am not seeing any errors in the output window.

I tried the static resource but a new view model doesn't do me any good.  My header labels come from the data (i.e. they are dynamic).

thanks!
0
Vera
Telerik team
answered on 05 Aug 2013, 08:08 AM
Hi Koren,

Please take a look at the attached project. Are you able to get the problem on it? In case you are not, will It be possible to modify the project and to send it back to us? We will debug it on our side in order to find the cause of the issue.

Thank you in advance.


Regards,
Vera
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Koren
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Koren
Top achievements
Rank 1
Vera
Telerik team
Share this question
or