[UWP]如何在特定网格单元格单击事件中添加带有timepicker控件的弹出窗口? [英] [UWP]How can I add a pop up with timepicker control in a particular grid cell click event ?

查看:50
本文介绍了[UWP]如何在特定网格单元格单击事件中添加带有timepicker控件的弹出窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的UWP。我有一个有两列和多行的网格(它在XAML中用于UWP应用程序)。当我单击第二列中的某些单元格时,它应显示带有时间选择器的弹出控件。那么,我如何将这些控件添加到网格单元格中?当
我选择该控件的时间时,它应该隐藏然后显示该单元格上的时间。

Hi, I'm new UWP. I have a grid with two columns and multiple rows (it is in XAML for UWP app). When I click some cells in second column it should display popup control with a time picker. So, how can I add these controls to a grid cell click and when I choose the time from that control it should hide then display the time on that cell.

可以你能告诉我怎么做。

Could you please tell me how to do this.

谢谢

推荐答案

嗨SJ87,



[2016年3月30日更新]欢迎来到开发通用Windows应用程序论坛!

请阅读粘贴帖子,尤其是
发布指南:主题行标签

Windows 10 SDK和工具的已知问题

$


如果你想要弹出包含 $ b $的控件b TimePicker 控件,然后您可以在xaml中定义弹出控件并默认将IsOpen设置为False。请参阅以下代码段。

Hi SJ87,

[Updated 3/30/2016]Welcome to the Developing Universal Windows apps forum!
Please read the sticky posts, especially the Guide to posting: subject line tags and Known Issues for Windows 10 SDK and Tools

If you want to popup a control which contains a TimePicker control, then you could define a Popup Control in xaml and set IsOpen to False by default. Please refer to the following code snippet.

        <Popup x:Name="popup" IsOpen="False">
            <StackPanel>
                <TimePicker x:Name="timePicker"/>
                <Button x:Name="submitBtn" Click="submitBtn_Click" Content="submit"/>
            </StackPanel>
        </Popup>


您可以在第二列中使用Button控件而不是Grid,并在xaml中订阅相同的Click事件。

And you could use Button control instead of Grid in second column and subscribe to the same Click event in xaml.

         <Grid>
            <Grid.RowDefinitions>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button Grid.Row="0" Grid.Column="1" Click="Button_Click"/>
            <Button Grid.Row="1" Grid.Column="1" Click="Button_Click"/>
        </Grid>


在代码背后,你可以这样做。

In code behind, you could do something like this.

        Button button;
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            button = sender as Button;
            popup.IsOpen = true;
        }

        private void submitBtn_Click(object sender, RoutedEventArgs e)
        {
            popup.IsOpen = false;
            button.Content = timePicker.Time.ToString();
        }


有关"添加TimePicker"的更多信息,请参阅以下链接。

https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn308517.aspx 
$


最好的问候,

David

For more information about "Adding a TimePicker", please refer to the following link.
https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn308517.aspx 

Best Regards,
David


这篇关于[UWP]如何在特定网格单元格单击事件中添加带有timepicker控件的弹出窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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