The best way to use RadPickerBox is to inherit from Silverlight’s Control class and use RadPickerBox as a part in the control’s ControlTemplate. This is exactly how RadDatePicker and RadTimePicker use it, they display the selected value in the content part, and the popup part contains the date and time selectors used to actually select the value.
[C#] Class declaration
public
class
SampleComboBox : Control
{
private
RadPickerBox pickerBox;
// rest of class omitted
}
[XAML] ControlTemplate
<
ControlTemplate
TargetType
=
"example:SampleComboBox"
>
<
telerikPrimitives:RadPickerBox
x:Name
=
"PART_PickerBox"
PopupPlacementTarget
=
"{Binding ElementName=LayoutRoot}"
Content
=
"{Binding ElementName=PART_ListBox, Path=SelectedItem}"
PopupOpenAnimation
=
"{TemplateBinding PopupOpenAnimation}"
PopupCloseAnimation
=
"{TemplateBinding PopupCloseAnimation}"
IsFullScreen
=
"True"/
>
<!-- Rest of template omitted -->
</
ControlTemplate
>
RadPickerBox exposes the full functionality of RadWindow, namely, relative placement of the popup, popup location offsets, open and close animations etc. Inheriting from Control and aggregating RadPickerBox allows developers to hide some of this functionality which is not applicable to the new control. For example RadDatePicker only exposes the window’s events, it does not expose relative placement, the ability to change the placement target or to change the window’s sizing mode. If on the other hand the new control requires all of this, developers can simply use the good old inheritance mechanism to utilize all of the functionality.
Usage of RadPickerBox has been designed to be fairly straightforward if used in the two ways described above. Our examples application provides the full implementation of the composition method (part of the code above) which creates a new control and uses RadPickerBox as an instance field in order to achieve the functionality of the well-known combo box UI component. Any feedback is greatly appreciated so please post questions, bug reports or feature requests on the forums.