Concrete Array element Binding

4 posts, 0 answers
  1. Prolifis
    Prolifis avatar
    8 posts
    Member since:
    Nov 2012

    Posted 24 Apr 2013 Link to this post

    Hi,

    How to achieve the following behavior: I need to show the concrete child (string type) from the parent container:

    <telerik:PropertyDefinition Binding="{Binding Container}">
        <telerik:PropertyDefinition.NestedProperties>
            <telerik:PropertyDefinition Binding="{Binding Children[0]}"/>                          
        </telerik:RadPropertyGrid.PropertyDefinitions>
    </telerik:PropertyDefinition>

    It does not enter the Children collection.
    I've tried to write the converter but the result - it shows combobox instead of textbox.

    public class EnumerableConverter : IValueConverter
        {
            public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
            {            
                var enumerable = (IEnumerable)value;
                var index = 0;
                var position = int.Parse((string) parameter);
                var enumerator = enumerable.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    if (index == position)
                    {
                        return enumerator.Current;
                    }
                    index++;               
                }
                return null;
            }

            public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
            {
                throw new NotImplementedException();
            }
        }

    Thanks
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 25 Apr 2013 Link to this post

    Hello Yuliya,

    If you want to return the name of the child, you can try binding it directly to it: {Binding Children[0].Name} (the right property you need to bind to, depends on your exact requirements. In case this approach does not work for your scenario, could you provide a bit more details ? What is the Container object - visual element, business object, etc. ? What exactly do you want to display for the first children ?

    Kind regards,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Prolifis
    Prolifis avatar
    8 posts
    Member since:
    Nov 2012

    Posted 25 Apr 2013 Link to this post

    Hi,

    I have collection of string values, i.e. smth. like this:

        public class MainViewModel : BaseViewModel
        {
            public ContainerViewModel Container {get;set;}      
        }

        public class ContainerViewModel : BaseViewModel
        {
            public ObservableCollection<string> Children { get; set; }
        }

    Do not get how to attach the sample solution, so I've used free file share:
    http://wikisend.com/download/280622/WpfApplication.zip

    Thanks!
  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 25 Apr 2013 Link to this post

    Hello Yuliya,

    Thank you for the provided information. As it turns out, currently RadPropertyGrid does not support such scenarios. Nevertheless, I will investigate the case to see whether we can improve this behavior. I will let you know once I have more information.

    Kind regards,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top