This is a migrated thread and some comments may be shown as answers.

how to wrap treeview control events

5 Answers 67 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
manjerekar
Top achievements
Rank 1
manjerekar asked on 05 Aug 2010, 10:57 AM
Hi Team,

I'm writing a wrapper class basically to enable only few of the properties and events from the RadTreeView control.

i want to enable the events

Selected

 

 

="radTreeView1_Selected" Expanded="radTreeView1_Expanded" Collapsed="radTreeView1_Collapsed"

 

of the RadTreeView control in my wrapper class. 

here is my wrapper class.

public

 

 

class TngTreeView : TngBaseControl

 

{

#region

 

 

Constructors

 

 

 

static TngTreeView()

 

{

DefaultStyleKeyProperty.OverrideMetadata(

 

typeof(TngTreeView), new FrameworkPropertyMetadata(typeof(TngTreeView)));

 

RegisterDependencyProperties(

 

typeof(TngTreeView), typeof(RadTreeView));

 

}

 

 

public TngTreeView()

 

{

InternalFrameworkElement =

 

new RadTreeView();

 

 

 

this.AddVisualChild(InternalFrameworkElement);

 

}

#endregion

#region

 

 

Internal Control

 

 

 

private RadTreeView TreeView

 

{

 

 

get

 

{

 

 

return InternalFrameworkElement as RadTreeView;

 

}

}

 

 

public RadTreeView InternalControl

 

{

 

 

get

 

{

 

 

return TreeView;

 

}

 

 

set

 

{

InternalControlSetter(TreeView,

 

value);

 

}

}

#endregion

 

 

 

#region

 

 

Property: ToolTip

 

 

 

public string ToolTip

 

{

 

 

get { return (string)TreeView.GetValue(RadTreeView.ToolTipProperty); }

 

 

 

set { TreeView.SetValue(RadTreeView.ToolTipProperty, value); }

 

}

#endregion


}

appreciate your help

Manjerekar Rao

5 Answers, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 05 Aug 2010, 02:43 PM
Hello manjerekar,

Could you elaborate a little on the problems you are encountering? Does registering for the TreeView events and re-raising them as custom events work in your case?

Regards,
Miroslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
manjerekar
Top achievements
Rank 1
answered on 05 Aug 2010, 04:01 PM
I haven't registered yet.
i want to register the TreeView events and re-raise them as custom events. how to do this?

do u have any contact no. to call you and do you provide instant chat facility.


help much appreciated
Manjerekar Rao
0
Miroslav
Telerik team
answered on 10 Aug 2010, 03:11 PM
Hi manjerekar,

If you want to expose simple CLR events this may happen like so:

public class TngTreeView
{
    RadTreeView treeView;
  
    public TngTreeView()
    {
        treeView.Expanded += new 
            EventHandler<RadRoutedEventArgs>(treeView_Expanded);
    }
  
    void treeView_Expanded(object sender, RadRoutedEventArgs e)
    {
        if (this.Expanded != null)
        {
            this.Expanded(this, e);
        }
    }
  
    public event EventHandler<RadRoutedEventArgs> Expanded;
}

We do not normally offer phone support - we will be happy to anwer your question here.

All the best,
Miroslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Srinivas
Top achievements
Rank 1
answered on 12 Aug 2010, 12:37 PM
Hi Miroslav,

These is with reference to your's and Manjurekar's post.

The answer that you repiled in code says that , the end user should use Telerik DLL to use those wraped events. which that we (manjurekar and me) not required . End user should use the DLL what we provided from the framework we are developing and able to use the events.


Thanks ,
Srinivas

0
Miroslav
Telerik team
answered on 17 Aug 2010, 08:32 AM
Hi Srinivas,

Yes, the Telerik dlls will be needed since the wrapper dlls will be referencing them. It will not be possible to wrap the Telerik controls without eventually using the dlls.

If you want to have a different public API, you can just expose an event with custom event args, say

public event EventHandler<MyEventArgs> Expanded;

All the best,
Miroslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TreeView
Asked by
manjerekar
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
manjerekar
Top achievements
Rank 1
Srinivas
Top achievements
Rank 1
Share this question
or