Not able to bind combox

Topics: Prism v4 - Silverlight 4
Feb 4, 2013 at 2:33 PM
Hi to all friends out there.

I have problem which i am facing.I am not able to bind combox by prism .
Here is my XAML
<telerik:RadComboBox Grid.Column="1" HorizontalAlignment="Left" Margin="10,3,0,0" Grid.Row="4" VerticalAlignment="Top" Width="79" Height="22" ItemsSource="{Binding marriageStatusList, Mode=TwoWay}" SelectedValue="{Binding Path=marriageStatusId, Mode=TwoWay}" DisplayMemberPath="StatusName" SelectedValuePath="MarriageStatusId" >
</telerik:RadComboBox>

My view model code is:-
ObservableCollection<HappyNagarAppService.FamilyTree_MarriageStatus> marriageStatusList { get; set; }

private void loadMarriageStatus()
    {

        proxy.getMarriageStatusCompleted += new EventHandler<HappyNagarAppService.getMarriageStatusCompletedEventArgs>(client_getMarriageStatusCompleted);
        proxy.getMarriageStatusAsync();
    }

    void client_getMarriageStatusCompleted(object sender, HappyNagarAppService.getMarriageStatusCompletedEventArgs e)
    {
        marriageStatusList = e.Result;

    }
and i am calling loadMarriageStatus() in constructor of viewmodel. Here is proxy is my proxy object of my wcf service.

please help me and let me what wrong i am doing due to which it is not binding.

Thanks in advance.
Developer
Feb 4, 2013 at 5:00 PM
Edited Feb 4, 2013 at 5:01 PM
Hi,

Based on my understanding, I believe that a possible cause for this behavior could be that you are replacing the marriageStatusList property with a new collection in your client_getMarriageStatusCompleted event handler. Hence, as the the collection only notifies a change when an item is added, removed or when the collection is refreshed, which in this case is not happening, you may have to invoke the RaisePropertyChanged method on this property after changing its value in order to properly notify the UI about this change. For example, this could be achieved like this:
 void client_getMarriageStatusCompleted(object sender, HappyNagarAppService.getMarriageStatusCompletedEventArgs e)
    {
 marriageStatusList = e.Result;
 this.RaisePropertyChanged(() => this.marriageStatusList);
    }
I hope this helps,

Agustin Adami
http://blogs.southworks.net/aadami
Feb 5, 2013 at 4:47 AM
Thanks aadami for your reply.

I tried but still it is not getting collection item in combox still. No Success yet
.Please help me . If you can please show me small code in wihch i get ersult in observable collection like in this i m getting.

It is getting very frustating to get this thing one .
I have dfiffult in radiobutton list also to set and get selected radiobutton from view to viewmodel.

Thanks and please help me to come out from this thing.
Developer
Feb 5, 2013 at 2:15 PM
Edited Feb 5, 2013 at 2:18 PM
Hi,

So far based on the code snippets you provided I couldn't find the reason for this behavior, in my case I haven't experimented with this particular control, but as a starting point, I believe you could check if your view's datacontext is being correctly set with the corresponding view model. Also, you could debug you application to see if the data is being correctly retrieved and set in your marriageStatusList property, take into account that as far as I know the collection retrieved from your service should be wrapped in a ObservableCollection<T> instance, for example using one of its constructors that take an IEnumerable<T> or List<T> parameter:
myProperty = new ObservableCollection<T>(Service.GetItemsList() );
Additionally, I believe you could check the following article from the Telerik site where a possible approach to Binding to WCF Service using the MVVM Approach is explained:
I hope you find this handy,

Agustin Adami
http://blogs.southworks.net/aadami