Quantcast
Viewing all articles
Browse latest Browse all 18858

How to Bind a List to DataGrid using MVVM at Runtime

All, I have an View model that is bound to a `DataGrid` using MVVM.

    <DataGrid ItemsSource="{Binding Path=Resources}">...</DataGrid>

Where

    public ObservableCollection<ResourceViewModel> Resources { get; private set; }

in the `ResourceViewModel` class I have the following properties

    public string ResourceName
    {
        get { return this.resource.ResourceName; }
        set {
            ...
        }
    }

    public ObservableCollection<string> ResourceStringList
    {
        get { return this.resource.ResourceStringList; }
        set {
            ...
        }
    }

All properties are displayed in the `DataGrid` but the `ResourceStringList` colletion is being displayed as '(Collection)'.

How can I get the `DataGrid` to display each of the strings contained in the `ResourceStringList` in its own column?

Thanks very much for your time.


"Everything should be made as simple as possible, but not simpler" - Einstein


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>