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

GridViewComboBox Column MVVM Binding

0 Answers 104 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.
Iftikhar
Top achievements
Rank 1
Iftikhar asked on 18 Apr 2012, 06:46 PM
Hi,

i am using telerik controls on silverlight. Our application is based on MVVM architecture and uses web services to fetch data from a db.
Usually we after fetching the data from db, all i have to do is to assign to an object in ViewModel, which is bound to ItemsSource or Text property of a control. However in case of GridView with ComboBox column i am unable to get values from the bound object. I have read many threads on this but could not find a solution. Here is my code:
XAML:
<br><Telerik:ExtRGridView x:Name="gw" SelectedItem="{Binding SelectedRow, Mode=TwoWay}" ItemsSource="{Binding ResultsData, Mode=TwoWay}" Margin="8" AutoGenerateColumns="False" IsReadOnly="True" CanUserInsertRows="False" CanUserDeleteRows="False">
 <Telerik:ExtRGridView.Columns>
   <telerikGridView:GridViewDataColumn DataMemberBinding="{Binding Name, Mode=TwoWay}" IsAutoGenerated="True" MinWidth="150"/>
<telerikGridView:GridViewComboBoxColumn ItemsSourceBinding="{Binding Agents, Mode=TwoWay}" DisplayMemberPath="Name" IsAutoGenerated="True" MinWidth="200" />
</Telerik:ExtRGridView.Columns>
 </
Telerik:ExtRGridView>


ViewModel:
public ObservableCollection<AutoQueueAssignTLData> ResultsData {
get
{return _ResultsData;}
set{ _ResultsData = value;
OnPropertyChanged(
"ResultsData ");
}
}


Misc Classes: [Defined on Server Side and are fetched via WebSvcs in Reference.cs]
public class AutoQueueAssignTLData
    {
        private AutomaticQueueingResGroupListBoxData _Name;
        private IList<AgentType> _Agents;
        private string _TeamLead;
 
        public string TeamLead
        {
            get { return _TeamLead; }
            set { _TeamLead = value; }
        }
 
        public IList<AgentType> Agents
        {
            get { return _Agents; }
            set { _Agents = value; }
        }
 
        public AutomaticQueueingResGroupListBoxData Name
        {
            get { return _Name; }
            set { _Name = value; }
        }
    }
public class AgentType{
   private string _Id;
 
       public string Id
       {
         get { return _Id; }
         set { _Id = value; }
       }
               private string _Name;
 
       public string Name
       {
         get { return _Name; }
         set { _Name = value; }
       }
       private bool _IsTL;
 
       public bool IsTL
       {
           get { return _IsTL; }
           set { _IsTL = value; }
       }
   }


Model:

((IView<AssignTLViewModel>)this.View).Model.ResultsData = data;


Explanation:
The requirement is such that we need two columns one with string values and other with a comboboxes. So i made an AutoQueueAssignTLData class and bound the ItemsSource of GridView to an ObservableCollection of the same type. Now this object has one string and a List type attribute, which are bound to DataColumn and ComboBox column respectively. However after webservice fetched data, I cant see comboboxes in the the respective column.
Note: I want different values in comboboxes so i bound them with a collection of lists.

Can any one find a mistake in this implementation?
Tags
GridView
Asked by
Iftikhar
Top achievements
Rank 1
Share this question
or