This is a migrated thread and some comments may be shown as answers.
GridViewComboBoxColumn problem
5 Answers 23 Views
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 21 Mar 2013, 09:23 PM
I've been stumbling all over this all day and need some direction.  I've paired down my code and am posting it in hopes that someone can tell me what I'm doing wrong.
The xaml...
<telerik:RadGridView AutoGenerateColumns="False"
                        ItemsSource="{Binding Screens}">
    <telerik:RadGridView.Columns>
        <telerik:GridViewComboBoxColumn x:Name="ScreenTypeCombo"
                                        UniqueName="ScreenTypeCombo"
                                        Header="Screen Type"
                                        Width="150"
                                        DataMemberBinding="{Binding SelectedScreenType}"
                                        SelectedValueMemberPath="ScreenType"
                                        DisplayMemberPath="Literal"
                                        ItemsSourceBinding="{Binding ScreenTypeLiterals}" />
    </telerik:RadGridView.Columns>


The ViewModel...

public enum ScreenTypes
{
    Master,
    Vertical,
    Multicolumn,
    Wrap,
    Detail,
    Transaction,
    Notes
}
 
public class ScreenTypeLiteral
{
    public ScreenTypes ScreenType
    {
        get;
        set;
    }
 
    public String Literal
    {
        get;
        set;
    }
 
    public ScreenTypeLiteral(ScreenTypes type, String lit)
    {
        ScreenType = type;
        Literal = lit;
    }
}
 
public class ScreenDescriptor
{
    public ICollectionView ScreenTypeLiterals
    {
        get
        {
            return _ScreenTypeLiterals;
        }
        set
        {
            _ScreenTypeLiterals = value;
            OnPropertyChanged(() => ScreenTypeLiterals);
        }
    }
    private ICollectionView _ScreenTypeLiterals;
 
    public ScreenTypeLiteral SelectedScreenType
    {
        get
        {
            return ScreenTypeLiterals.CurrentItem as ScreenTypeLiteral;
        }
    }
 
    public ScreenDescriptor()
    {
        ScreenTypeLiterals = CollectionViewSource.GetDefaultView(new List<ScreenTypeLiteral>()
        {
            {new ScreenTypeLiteral(ScreenTypes.Master, "Master View")},
            {new ScreenTypeLiteral(ScreenTypes.Vertical, "Detail View")},
        });
        ScreenTypeLiterals.MoveCurrentToFirst();
    }
 
}
 
public class Descriptor
{
    public ICollectionView Screens
    {
        get
        {
            return _screens;
        }
        set
        {
            _screens = value;
            OnPropertyChanged(() => Screens);
        }
    }
    private ICollectionView _screens = null;
 
    public Descriptor()
    {
        var list = new List<ScreenDescriptor>();
        list.Add(new ScreenDescriptor());
        list.Add(new ScreenDescriptor());
 
        Screens = CollectionViewSource.GetDefaultView(list);
        Screens.MoveCurrentToFirst();
    }
 
}


Thanks in advance,
Steve

5 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 22 Mar 2013, 04:06 PM
Hello,

I would suggest you to read through the online documentation on how to configure the GridViewComboBoxColumn properly.

Please let me know if you have any additional questions. 

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Steve
Top achievements
Rank 1
answered on 22 Mar 2013, 05:16 PM
I have read the documentation and searched the forums, and as far as I can see, I am doing everything correctly; however no data is displayed, and the ComboBox is not even displayed.  See the attached file and please review the code I posted.  If you need further information, please let me know.
Thank you,
Steve
0
Accepted
Dimitrina
Telerik team
answered on 25 Mar 2013, 07:48 AM
Hello,

Please note that the source set for the ItemsSourceBinding should be a property of the business object the grid row is bound to. Looking at the provided source code, this is correct. Then the DataMemberBinding is set to SelectedScreenType which is set to ScreenTypeLiterals.CurrentItem. Is there a value set for the ScreenTypeLiterals.CurrentItem?

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Steve
Top achievements
Rank 1
answered on 25 Mar 2013, 06:18 PM
Hi Didie,
Your response caused me to look again at how the DataMemberBinding was assigned and I found two things that were a problem.  First, the type of the property should have been ScreenTypeLiteral.ScreenType.  The second, and I'm not sure why was returning the CurrentItem of the collection.  By creating a field behind the SelectedScreenType of ScreenTypeLiteral.ScreenType and assigning the CurrentItem to it on the ICollectionView.CurrentChanged event, all work correctly.  My suspicion is the the second problem my have something to do with the absence of the IsSynchronizedWithCurrentItem property on the ComboBoxColumn.
Thanks for your help,
Steve
0
Dimitrina
Telerik team
answered on 26 Mar 2013, 02:24 PM
Hello Steve,

I am glad to hear that you have resolved the issue. Thank you for sharing the solution with the community.

All the best,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Asked by
Steve
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Steve
Top achievements
Rank 1
Share this question
or