Xml bind + Command Buttons?

1 posts, 0 answers
  1. ITA
    ITA avatar
    383 posts
    Member since:
    Aug 2009

    Posted 28 Jun 2011 Link to this post

    Hi,

    i have a working RadGridView with an XML-File which is bind by XMLDataProvider. I want to use a Telerik RadButton with a Command to insert, delete or edit Rows. But it does not work:

    CODE:
                                                            <StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="left" Margin="0,5,0,0">
                                                                <telerik:RadButton Width="100" Content="Delete selected rows" Margin="0,0,5,0"
                                                                                    Command="telerikGrid:RadGridViewCommands.Delete" CommandTarget="{Binding ElementName=radGridView2}"  />
                                                                <telerik:RadButton Width="100" Content="Add new row" Margin="0,0,5,0"
                                                                                    Command="telerikGrid:RadGridViewCommands.BeginInsert" CommandTarget="{Binding ElementName=radGridView2}"  />
                                                                <telerik:RadButton Width="100" Content="Save insert/edit" Margin="0,0,5,0"
                                                                                    Command="telerikGrid:RadGridViewCommands.CommitEdit" CommandTarget="{Binding ElementName=radGridView2}"  />
                                                                <telerik:RadButton Width="100" Content="Cancel insert/edit"
                                                                                    Command="telerikGrid:RadGridViewCommands.CancelRowEdit" CommandTarget="{Binding ElementName=radGridView2}"  />
                                                            </StackPanel>
                                                            <Grid Grid.Row="1">                                                           
                                                                <Grid.Resources>
                                                                    <XmlDataProvider x:Key="MADSource" Source="settings\mandanten.xml" XPath="//Attributes/Attribute[@AttributeGroup='Mandant']"></XmlDataProvider>
                                                                </Grid.Resources>
                                                                <telerik:RadGridView Visibility="Visible" x:Name="radGridView2" AutoGenerateColumns="False" ItemsSource="{Binding Source={StaticResource MADSource}}"
                                                                                     CanUserDeleteRows="True" CanUserInsertRows="True" IsReadOnly="False" ShowGroupPanel="False" SelectionMode="Extended">
                                                                    <telerik:RadGridView.Columns>
                                                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding XPath=ContentAttribute[@AttributeName\=\Name] }" Header="Name" Width="120">
                                                                            <telerik:GridViewDataColumn.CellTemplate>
                                                                                <DataTemplate>
                                                                                    <ContentControl Content="{Binding XPath=ContentAttribute[@AttributeName\=\'Name\']}">
                                                                                    </ContentControl>
                                                                                </DataTemplate>
                                                                            </telerik:GridViewDataColumn.CellTemplate>
                                                                        </telerik:GridViewDataColumn>
                                                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding XPath=ContentAttribute[@AttributeName\=\Host] }" Header="Host" Width="100">
                                                                            <telerik:GridViewDataColumn.CellTemplate>
                                                                                <DataTemplate>
                                                                                    <ContentControl Content="{Binding XPath=ContentAttribute[@AttributeName\=\'Host\']}">
                                                                                    </ContentControl>
                                                                                </DataTemplate>
                                                                            </telerik:GridViewDataColumn.CellTemplate>
                                                                        </telerik:GridViewDataColumn>
                                                                        <telerik:GridViewDataColumn DataMemberBinding="{Binding XPath=ContentAttribute[@AttributeName\=\Port] }" Header="Port" Width="50">
                                                                            <telerik:GridViewDataColumn.CellTemplate>
                                                                                <DataTemplate>
                                                                                    <ContentControl Content="{Binding XPath=ContentAttribute[@AttributeName\=\'Port\']}">
                                                                                    </ContentControl>
                                                                                </DataTemplate>
                                                                            </telerik:GridViewDataColumn.CellTemplate>
                                                                        </telerik:GridViewDataColumn>
                                                                    </telerik:RadGridView.Columns>
                                                                </telerik:RadGridView>
    CODEBEHIND:
        Public Sub New()

            Dim deleteCommand As ICommand = RadGridViewCommands.Delete
            Dim beginInsertCommand As ICommand = RadGridViewCommands.BeginInsert
            Dim cancelRowEditCommand As ICommand = RadGridViewCommands.CancelRowEdit
            Dim commitEditCommand As ICommand = RadGridViewCommands.CommitEdit

            InitializeComponent()
        End Sub

    I get no errors, but the buttons do not work and i can't edit the Columns. HELP!!!
    Rene
Back to Top