How can I tell the ListCollectionView that Telerik PropertyGrid uses?

I am using PropertyGrid to view, edit, add and remove property values โ€‹โ€‹of an outer class that I cannot change. Class contains many properties List<string>

, List<int>

, List<Guid>

so I can not add value to these lists by using the PropertyGrid, because he does not know how to create them.

So my initial idea was to wrap each type using a class that looks like this:

public class ValueOf<T>
{
   public T Value { get; set; }

   public ValueOf()
   {
       Value = default(T);
   }

   public ValueOf(T valueContent)
   {
       Value = valueContent;
   }
}

      

... but that means I'll have to use the View Model for this class. I cannot modify and write each property like this:

public ObservableCollection<ValueOf<string>> Names{ get; set; }

      

So I searched a little more and found this link: http://www.michaelruck.de/2012_07_01_archive.html

It talks about writing a custom ListCollectionView to add to work in the DataGrid, but that looks like it would work for PropertyGrid as well. Something seems to like this:

public class TypedListCollectionView<T> : ListCollectionView, IEditableCollectionView
{
    private Func<T> factory;

    public TypedListCollectionView(IList collection, Func<T> factory)
        : base(collection)
    {
        this.factory = factory;
    }

    bool IEditableCollectionView.CanAddNew
    {
        get
        {
            return this.CanAddNewItem;
        }
    }

    object IEditableCollectionView.AddNew()
    {
        T obj = this.factory();
        return this.AddNewItem(obj);
    }
}

      

My question is, how can I tell which ListCollectionView the PropertyGrid should use? I'm new to WPF and it seems like I am missing something.

+3
c # telerik wpf


source to share


No one has answered this question yet

Check out similar questions:

3575
How to list an enumeration?
2058
How do I get a consistent byte representation of strings in C # without manually specifying the encoding?
1877
What is a NullReferenceException and how do I fix it?
1742
How to calculate a person's age in C #?
1270
Why not inherit from List <T>?
319
Public fields and automatic properties
18
How to use factory for DataGrid.CanUserAddRows = true
1
Generic TypeConverter for PropertyGrid
0
How to bind ObservableCollection to DataGridComboBoxColumn in DataGrid?
0
Advanced WPF Toolkit PropertyGrid IsExpandable Template



All Articles
Loading...
X
Show
Funny
Dev
Pics