Setting ItemsSource fails to load Items

2 posts, 0 answers
  1. Joe
    Joe avatar
    1 posts
    Member since:
    Oct 2013

    Posted 21 Nov 2013 Link to this post

    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:RadGridView x:Name="MyGridView" CanUserDeleteRows="False"
                                    Height="200" Width="290"
                                    telerik:StyleManager.Theme="Office_Blue" ShowGroupPanel="False"
                                    RowIndicatorVisibility="Collapsed" AutoGenerateColumns="false">
                    <telerik:GridViewDataColumn x:Name="MyColumn" Header="Description"
                                                Width="280" DataMemberBinding="{Binding Description}"
                                                IsReadOnly="True" />

    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,

  2. Yoan
    Yoan avatar
    1215 posts

    Posted 26 Nov 2013 Link to this post

    Hi Joe,

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

    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 >>
Back to Top