Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set d:DesignInstance to a generic type? [duplicate]

An easy one ;-)

I declared:

     xmlns:om="clr-namespace:System.Collections.ObjectModel;assembly=System"

I try to set a generic as the DataType:

 <DataGrid d:DataContext="{
     d:DesignInstance Type=om:ObservableCollection&lt;System:Int32&gt;}" />

But I'm receiving an error: "Invalid format for a type".

Anybody have an idea how I can do that ?

like image 451
Eric Ouellet Avatar asked Jul 27 '10 00:07

Eric Ouellet


2 Answers

Generics are not supported yet. We can derive a class from any generics and use that class instead.

Oops, please see comment below from "Jan 'splite'K". It sounds that there is a markup extension that could do the job.

Also, look at uli78 link

Update 2021-09-30 , I think a great answer is given here: How do I set WPF xaml form's Design DataContext to class that uses generic type parameters (thanks to Revious for its comment)

like image 54
Eric Ouellet Avatar answered Nov 17 '22 19:11

Eric Ouellet


You could try this:

<DataGrid d:DataContext="{d:DesignInstance Type={x:Type om:ObservableCollection`1}}" />
like image 32
Setyo N Avatar answered Nov 17 '22 20:11

Setyo N