如何显示的DatePicker和放大器; TimePicker控制通过包含它们的POPOP? [英] How to show DatePicker & TimePicker controls over the Popop that contains them?

查看:268
本文介绍了如何显示的DatePicker和放大器; TimePicker控制通过包含它们的POPOP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建的Windows Phone工具包的DatePicker&放一个弹出; TimePicker,用下面的XAML:

I'm trying to create a popup with Windows Phone Toolkit DatePicker & TimePicker, with the following XAML:

<Popup x:Name="MyPopup">

    <Border BorderThickness="2" Margin="10" BorderBrush="{StaticResource PhoneAccentBrush}">

        <StackPanel>

            <toolkit:DatePicker Name="datePicker" />
            <toolkit:TimePicker Name="timePicker"/>

        </StackPanel>

    </Border>
</Popup>

这工作,但我每次点击其中任何一个的时候,他们都弹出下呈现,如:

This works, but every time I click either of them, they are rendered under the popup, e.g.

我不能在显示的DatePicker和TimePicker想出什么办法来隐藏弹出。

I can't figure out any way to hide the Popup while displaying the DatePicker or TimePicker.

我试过设置在Z控件 - 索引都要比弹出更大,具体如下:

I've tried setting the Z-Index of the controls to be greater than the Popup, as follows:

void timePicker_GotFocus(object sender, RoutedEventArgs e)
{
    Canvas.SetZIndex(timePicker, Canvas.GetZIndex(MyPopup) + 1);
}



我也试着隐藏弹出式以

I've also tried hiding the Popup with

void timePicker_GotFocus(object sender, RoutedEventArgs e)
{
    Popup.IsOpen = false;
}



但关闭弹出和TimePicker / DatePicker的。

but this closes the popup and the TimePicker/DatePicker.

有什么办法来查看,在弹出的控制的顶部的DatePicker / TimePicker控件?

Is there any way to view the DatePicker/TimePicker controls on top of the Popup control?

推荐答案

示例项目。

XAML

XAML

    <Border
        Background="{StaticResource PhoneChromeBrush}"
        BorderThickness="2"
        Margin="10"
        BorderBrush="{StaticResource PhoneAccentBrush}">

        <StackPanel>

            <toolkit:DatePicker
                Tap="DatePickerTap" />

            <toolkit:TimePicker
                Tap="DatePickerTap" />

        </StackPanel>

    </Border>
</Popup>



后面的代码

Code behind

private bool pickerIsOpen = false;

// constructor
public MainPage()
{
    InitializeComponent();

    this.Loaded += this.MainPageLoaded;
}

// page loaded
private void MainPageLoaded(object sender, RoutedEventArgs e)
{
    if (this.pickerIsOpen)
    {
        this.MyPopup.IsOpen = true;
        this.pickerIsOpen = false;
    }
}

// date/time picker tap
private void DatePickerTap(object sender, System.Windows.Input.GestureEventArgs e)
{
    this.pickerIsOpen = true;
}

这篇关于如何显示的DatePicker和放大器; TimePicker控制通过包含它们的POPOP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆