Reputation: 1705
I want to use only the chooser dialog (shown below)
from the TimePicker control included in the Silverlight Toolkit for Windows Phone. Normally this dialog only appears when a user clicks on the TimePicker control listbox.
I would like to bypass the listbox altogether and launch the chooser dialog when a button is pressed.
Is this possible or would I have to create a custom control for myself.
Upvotes: 2
Views: 849
Reputation: 8126
Create class that inherited from TimePicker
, and use ClickTemplateButton()
to simulate click behavior:
public class CustomPicker : TimePicker
{
public void ClickTemplateButton()
{
Button button = (GetTemplateChild("DateTimeButton") as Button);
ButtonAutomationPeer peer = new ButtonAutomationPeer(button);
IInvokeProvider provider = (peer.GetPattern(PatternInterface.Invoke) as IInvokeProvider);
provider.Invoke();
}
}
When this class is created, create CustomPicker
in xaml. Don't forget to add xmlns
xmlns:local="clr-namespace:CustomPickerNamespace"
<local:CustomPicker x:Name="customPicker" .../>
And then call you can show it from code:
customPicker.ClickTemplateButton()
Upvotes: 4