Combo Box for DataGridComboBoxColumn only shows momentarily and other problems

2 posts, 0 answers
  1. Kevin
    Kevin avatar
    1 posts
    Member since:
    Jun 2017

    Posted 04 Jun Link to this post

    This is on Windows 10 Creators Update, Visual Studio 2017, Universal Windows Platform SDK 5.3.3, Telerik.UI.for.UniversalWindowsPlatform 1.0.0.3 from NuGet.  (Don’t know if any of these are significant)

    I’m encountering three problems when trying to use the control in my app.  Code is attached that reproduces the problems in a UWP.

    1) When I create a RadDataGrid with a DataGridComboBoxColumn, the popup menu shows then quickly goes away.  There is no way to change the selection.  Once in a while the pop did stay up but I can’t figure out how to make that happen reliably.

    2) If the row data is a list of ExpandoObjects, an exception will get thrown when canceling the edit.  If I switch to an array of class instances this doesn’t happen.  To reproduce this, run the attached code and cancel an edit operation.  You can switch to using non-dynamic instances to see it not happen.  This is important for my app because the columns are all generated dynamically.

    3) Lastly, trying to use a List<> of strings as the source of combobox items seems to throw an exception.  The code is disabled in the sample.  To enable it, change the if(false) on the last block to true.  I really think there must be something I'm doing wrong here since it's such a basic case.

    I'm new to these controls so I’d love to hear I’m doing something wrong.  If that’s not the case, are there workarounds?  Like use the Template column?

    If I want to dig into the GitHub code, are there any pointers to get started?  Like what events would be important to look for, what code handles bringing up the box, etc.?

    Thanks for any help. 
    Kevin

     

    MainPage.xaml

    <Page
        x:Class="RadDataGridTest.MainPage"
        xmlns:local="using:RadDataGridTest"
        xmlns:telerikGrid="using:Telerik.UI.Xaml.Controls.Grid"
        mc:Ignorable="d">
     
        <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            <telerikGrid:RadDataGrid x:Name="RadDataGrid"/>
        </Grid>
    </Page>

     

    MainPage.xaml.cs

    using System.Collections.Generic;
    using System.Dynamic;
    using Telerik.UI.Xaml.Controls.Grid;
    using Windows.UI.Xaml.Controls;
     
    namespace RadDataGridTest
    {
        public class EyeColor
        {
            public string DisplayName { get; set; }
        }
     
        public class Person
        {
            public string PersonName { get; set; }
            public EyeColor EyeColor { get; set; }
            public string EyeColorName { get; set; }
            public string EyeColorNameFromStringList { get; set; }
        }
     
        public sealed partial class MainPage : Page
        {
            public MainPage()
            {
                this.InitializeComponent();
     
                var eyeColorList = new List<EyeColor>();
                eyeColorList.Add(new EyeColor() { DisplayName = "Red" });
                eyeColorList.Add(new EyeColor() { DisplayName = "Green" });
                eyeColorList.Add(new EyeColor() { DisplayName = "Blue" });
     
                var eyeColorStringList = new List<string>();
                foreach (var eyeColor in eyeColorList) eyeColorStringList.Add(eyeColor.DisplayName);
                          
                // Make a set of rows that are class instances
                var classInstanceRows = new List<Person>();
                classInstanceRows.Add(new Person() { PersonName = "Bill", EyeColor = eyeColorList[0], EyeColorName = eyeColorList[0].DisplayName, EyeColorNameFromStringList = eyeColorList[0].DisplayName });
                classInstanceRows.Add(new Person() { PersonName = "Jane", EyeColor = eyeColorList[1], EyeColorName = eyeColorList[1].DisplayName, EyeColorNameFromStringList = eyeColorList[1].DisplayName });
     
                // Make a set of rows that are dynamic object instances
                var dynamicRows = new List<ExpandoObject>();
                foreach(var classInstanceRow in classInstanceRows)
                {
                    dynamic row = new ExpandoObject();
                    row.PersonName = classInstanceRow.PersonName;
                    row.EyeColor = classInstanceRow.EyeColor;
                    row.EyeColorName = classInstanceRow.EyeColorName;
                    row.EyeColorNameFromStringList = classInstanceRow.EyeColorNameFromStringList;
                    dynamicRows.Add(row);
                }
     
                if (false)
                {
                    // Use the class instances
                    this.RadDataGrid.ItemsSource = classInstanceRows;
                }
                else
                {
                    // Use the dynamic object instances
                    // !!!!! An exception will be thrown when you cancel an edit in the UI
                    this.RadDataGrid.ItemsSource = dynamicRows;
                }
     
     
                // Setup the RadDataGrid
                this.RadDataGrid.FrozenColumnCount = 1;
                this.RadDataGrid.AutoGenerateColumns = false;
                this.RadDataGrid.UserEditMode = DataGridUserEditMode.Inline;
     
                {
                    var textColumn = new DataGridTextColumn();
                    textColumn.Header = "Person Name";
                    textColumn.PropertyName = "PersonName";
                    this.RadDataGrid.Columns.Add(textColumn);
                }
     
                { // Column that gets its items from an array of classes and stores a class reference in the row data
                    var comboBoxColumn = new DataGridComboBoxColumn();
                    comboBoxColumn.Header = "Stored as reference";
                    comboBoxColumn.ItemsSource = eyeColorList;
                    comboBoxColumn.DisplayMemberPath = "DisplayName";
                    comboBoxColumn.PropertyName = "EyeColor";
                    this.RadDataGrid.Columns.Add(comboBoxColumn);
                }
     
                { // Column that gets its items from an array of classes and stores a string row data
                    var comboBoxColumn = new DataGridComboBoxColumn();
                    comboBoxColumn.Header = "Stored as string";
                    comboBoxColumn.ItemsSource = eyeColorList;
                    comboBoxColumn.DisplayMemberPath = "DisplayName";
                    comboBoxColumn.SelectedValuePath = "DisplayName";
                    comboBoxColumn.PropertyName = "EyeColorName";
                    this.RadDataGrid.Columns.Add(comboBoxColumn);
                }
     
                if(false) // !!! setting this to true will throw an exception on the first Measure operation
                { // Column that gets its items from an array of strings and stores a string in the row data
                    var comboBoxColumn = new DataGridComboBoxColumn();
                    comboBoxColumn.Header = "Stored as string from list of strings"; // "Eye Color by string from string list";
                    comboBoxColumn.ItemsSource = eyeColorStringList;
                    comboBoxColumn.PropertyName = "EyeColorNameFromStringList";
                    this.RadDataGrid.Columns.Add(comboBoxColumn);
                }
            }
        }
    }

     

     

  2. Nasko
    Admin
    Nasko avatar
    691 posts

    Posted 05 Jun Link to this post

    Hi Kevin,

    We are glad to here that you are using our UI for UWP Repository. In order to receive guidance and advises for the observed by you issues we suggest you to log them in the issues section of the repository.

    There the issues could be available for the other members of the Github community and you will be able to receive fast and accurate answers.

    We hope that this information will be helpful for you.

    Regards,
    Nasko
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top