Recently, a simple tree structure needs to be made into a user Widget But after the Treeview has been formed, when the user control is called elsewhere, the expected events of the Treeview are gone, such as the unchecked and checked events, in the following Xmal Code Without these events, you can actually implement these events in the user control, but some things cannot be implemented in the user control and can only be implemented by the caller.
< Local: resourcecategorytree X: Name = " Radtreeview1 " > </ Local: resourcecategorytree >
After an hour of exploration, I finally got it done. The implementation method is as follows:
1. First declare the required event in the user control, such as the unchecked event, as shown in the following code:
Public Event Telerik. Windows. radroutedeventhandler unchecked;
2. Implement the unchecked that comes with the Treeview in the user control. The Code is as follows:
Private Void Rtv_unchecked ( Object Sender, telerik. Windows. radroutedeventargs E)
{
//Trigger custom events
If(Unchecked! = Null)
{
Unchecked (sender, e );
}
}
3. the unchecked event can be implemented by the caller. It can be implemented in XAML or in background code. The following code is implemented in the background:
Radtreeview1.unchecked + = New Telerik. Windows. radroutedeventhandler (radtreeview1_unchecked );
4. The following code is the implementation method.
Private Void Radtreeview1_unchecked ( Object sender, telerik. windows. radroutedeventargs e)
{
// This event code is ready
}
after the preceding steps, this allows you to implement custom controls in user controls on the caller.
In addition, The Treeview control I use is a third-party control, if you use Microsoft the built-in control of the system changes the namespace and Class.