View previous topic :: View next topic |
Author |
Message |
mwe
Joined: 08 Dec 2005 Posts: 15
|
Posted: Tue Oct 10, 2006 1:01 pm Post subject: Can't get ObjectBinding to generic type to work |
|
|
I'm trying to bind VirtualTree to a generic type by specifying for example Equin.ApplicationFramework.EditableObject<STS.Objects.Document> for TypeName in the object binding. However, I keep getting some default binding (i.e. the type name is shown in the tree) when adding such objects to the data source being visualized in the tree. So what am I expected to specify as type name? _________________ Kind regards
Magnus Werner, System Architect
------------------------------------------
Saab Training Systems AB |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Oct 11, 2006 12:00 am Post subject: |
|
|
Because of the way Object binding uses reflection to bind to the type you can't currently simply use the qualified generic type name in the bindings editor. The simplest way around this is to use the GetBinding event to programmatically set the binding to use for generic types eg:
Code: | private void _virtualTree_GetBinding(object sender, GetBindingEventArgs e)
{
if (e.Item is Part<int>)
{
e.RowBinding = this.rowBindingPart;
}
else
{
// use default binding for all other items
//
e.RowBinding = _virtualTree.GetRowBinding(e.Item);
}
} |
We will have a look and see whether we can modify the normal (ie using the typename) mechanism to cope with generic types in the next release. _________________ Infralution Support |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Nov 20, 2006 5:01 am Post subject: |
|
|
This issue has now been addressed in Version 3.2.0. You can now specify generic types at design time in the RowBindings editor. You do however have to be careful to provide full assembly qualified type names for both the generic type and parameter type eg
Code: | MyNamespace.MyGenericType<MyNamespace.MyType, MyAssembly>, MyAssembly |
You also cannot use language defined type names (eg int for C#). Instead you must specify the underlying system type eg
Code: | MyNamespace.MyGenericType<System.Int32>, MyAssembly |
Note an alternative to the method provided earlier in this thread is to simpy set the rowBinding.Type property in the form constructor
Code: | rowBindingPart.Type = typeof(Part<int>); |
_________________ Infralution Support |
|
Back to top |
|
|
|