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

Setting ItemsSource fails to load Items

1 Answer 75 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 22 Nov 2013, 04:04 AM
Hi there,

I'm currently upgrading a large Silverlight project from RadControls for Silverlight Q2 2011 SP1 to RadControls for Silverlight Q3 2013 and I'm finding that in some instances the setting (in the code behind) of the ItemsSource of the RadGridView does not cause the Items to be populated and HasItems remains false.

By way of example, we have a RadGridView inside of the DropDownContent of a RadDropDownButton:

<telerik:RadDropDownButton x:Name="MyDropDownButton" Grid.Row="1" Grid.Column="1"
                           Margin="0,2" Height="25" Width="300" HorizontalContentAlignment="Left"
                           Content="{Binding Description}" telerik:StyleManager.Theme="Office_Blue">
    <telerik:RadDropDownButton.DropDownContent>
        <telerik:RadGridView x:Name="MyGridView" CanUserDeleteRows="False"
                                Height="200" Width="290"
                                telerik:StyleManager.Theme="Office_Blue" ShowGroupPanel="False"
                                RowIndicatorVisibility="Collapsed" AutoGenerateColumns="false">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn x:Name="MyColumn" Header="Description"
                                            Width="280" DataMemberBinding="{Binding Description}"
                                            IsReadOnly="True" />
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
    </telerik:RadDropDownButton.DropDownContent>
</telerik:RadDropDownButton>

The code behind simply sets the ItemsSource to the result of a service call. e.Result is an ObservableCollection of custom types that implement INotifyPropertyChanged:

void service_Completed(object sender, Service.CompletedEventArgs e)
{
    MyGridView.ItemsSource = e.Result;
}

When MyDropDownButton is opened for the first time, MyGridView.Items is still not populated and the count is 0. Upon subsequently opening MyDropDownButton I find that the MyGridView.Items are now populated and count reports the expected value.

I have already read here that the grid isn't bound whilst the grid's visibility is Collapsed. So I half suspect that this may be the cause. However, in the course of my investigations I have created a small demo project with the exact same scenario and found that the above described behavior is not exhibited; after setting the ItemsSource, the grid is immediately bound. This has left me rather confused.

Further, we also have code in some of these 'dropdown grids' that attempt to set the SelectedItem property of the grid from within the RadDropDownButton's DropDownOpened event. Now this obviously fails because the grid is empty during the first opening.

Thanks in advance for any help anyone can provide,

Joe

1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 26 Nov 2013, 11:49 AM
Hi Joe,

I have just replied to the other thread on the same topic.

Regards,
Yoan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
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
Joe
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or