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

[Solved] Data Binding issue

1 Answer 113 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Aprile Salvatore
Top achievements
Rank 1
Aprile Salvatore asked on 01 Sep 2009, 07:49 AM
Hello,
I'm experiencing a problem with RadGridView for Silverlight.

I have a grid, whose ItemSource is bound to a property of the ViewModel.
This grid is made of some columns, bound to some property of each item in ItemSource, and two additional button columns whose command SHOULD be bound to other properties of the ViewModel, and not to the properties of an item in ItemSource.

Is this scenario supported and how?

Thanks.

Attached is the grid code:

<telerikGridView:RadGridView  
            Height="250"
            VerticalAlignment="Top"
            IsFilteringAllowed="False"
            ShowGroupPanel="False"
            Margin="0,5,0,0"
            Grid.Row="1"
            Grid.Column="0"
            AutoGenerateColumns="False"
            ColumnsWidthMode="Auto"
            IsReadOnly="True"
            MultipleSelect="False"
            x:Name="gridExample"
            CCRadGridViewCommands:SelectionChanged.Command="{Binding SomeCommand}"
            ItemsSource="{Binding Path=PersonList}">

            <telerikGridView:RadGridView.Columns>
                <telerikGridView:GridViewDataColumn Header="Name" TextAlignment="Left" DataMemberBinding="{Binding PersonName}" />
                <telerikGridView:GridViewDataColumn Header="Surname" TextAlignment="Left" DataMemberBinding="{Binding PersonSurname}" />
                
                <telerikGridView:GridViewColumn Header="">
                    <telerikGridView:GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <Button x:Name="btnViewDetails" Content="Details" CCButtonCommands:Click.Command="{Binding ViewDetailsClickCommand}" ></Button>
                        </DataTemplate>
                    </telerikGridView:GridViewColumn.CellTemplate>
                </telerikGridView:GridViewColumn>
                <telerikGridView:GridViewColumn Header="">
                    <telerikGridView:GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <Button x:Name="btnViewData" Content="Data" CCButtonCommands:Click.Command="{Binding ViewDataClickCommand}" ></Button>
                        </DataTemplate>
                    </telerikGridView:GridViewColumn.CellTemplate>
                </telerikGridView:GridViewColumn>
            </telerikGridView:RadGridView.Columns>

        </telerikGridView:RadGridView>

1 Answer, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 01 Sep 2009, 03:00 PM
Hi Aprile Salvatore,

In your code snippet I couldn't find where you set a proper DataContext for the RadGridView, also no source is given to the ItemsSource binding.
I'm attaching an example which demonstrates how to bind RadGridView using Model-View-View Model pattern.
Hope this helps.

All the best,
Nedyalko Nikolov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Aprile Salvatore
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Share this question
or