Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Can't get ObjectBinding to generic type to work

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
mwe



Joined: 08 Dec 2005
Posts: 15

PostPosted: Tue Oct 10, 2006 1:01 pm    Post subject: Can't get ObjectBinding to generic type to work Reply with quote

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
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Oct 11, 2006 12:00 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Mon Nov 20, 2006 5:01 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group