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

How to bind to XML Attribute (XPath=@ID)?

1 Answer 223 Views
GridView
This is a migrated thread and some comments may be shown as answers.
YYZRichard
Top achievements
Rank 2
YYZRichard asked on 28 Jan 2011, 02:42 AM
I just switched from .NET DataGrid to RadGridView, but the bindings don't work like in the DataGrid. In RadGridView, all rows are empty. I've looked everywhere, and I haven't found any examples of how to use XPATH in RadGridView. I'd appreciate if you could help me to troubleshoot the bindings below. Thank you.

<telerik:RadGridView Grid.Column="1"
                             Grid.Row="1"
                             AutoGenerateColumns="False"
                             DataContext="{Binding MyXMLDoc}"
                             ItemsSource="{Binding XPath=/Nodes/Node}"
                             RowIndicatorVisibility="Collapsed"
                             ShowGroupPanel="False"
                             GridLinesVisibility="Horizontal">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn Width="200"
                                            DataMemberBinding="{Binding XPath=@Key}">
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" VerticalAlignment="Top" >
                                <Image Source="{Binding XPath=@Icon}" ToolTip="{Binding XPath=@Tooltip}" Style="{StaticResource ico16}" />
                                <TextBlock Text="{Binding XPath=@Key}" Foreground="Black" />
                            </StackPanel>
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                </telerik:GridViewDataColumn>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 03 Feb 2011, 08:34 AM
Hi YYZRichard,

 I've tried to recreate a scenario where the DataGrid will work in such case and RadGridView will not however everything worked as expected on my end - you can find an example project attached for reference. 

Can you send us small example where we can observe such wrong behavior? 

Regards,
Vlad
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
GridView
Asked by
YYZRichard
Top achievements
Rank 2
Answers by
Vlad
Telerik team
Share this question
or