TimePicker无文本框 [英] TimePicker without the TextBox
问题描述
我想只用选择对话框(如下所示)
I want to use only the chooser dialog (shown below)
从TimePicker控制包含在Silverlight工具包的Windows手机。只有当用户点击TimePicker控制列表框,通常会出现该对话框。
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.
推荐答案
创建
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();
}
}
在创建这个类,创建 CustomPicker
在XAML。不要忘了添加的xmlns
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()
这篇关于TimePicker无文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!