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

Concrete Array element Binding

3 Answers 87 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Prolifis
Top achievements
Rank 1
Prolifis asked on 24 Apr 2013, 01:25 PM
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

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 25 Apr 2013, 01:11 PM
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.

0
Prolifis
Top achievements
Rank 1
answered on 25 Apr 2013, 02:22 PM
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!
0
Maya
Telerik team
answered on 25 Apr 2013, 07:41 PM
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.

Tags
PropertyGrid
Asked by
Prolifis
Top achievements
Rank 1
Answers by
Maya
Telerik team
Prolifis
Top achievements
Rank 1
Share this question
or