当前位置: 首页>>代码示例>>C#>>正文


C# StackPanel.ControlsEnable方法代码示例

本文整理汇总了C#中Windows.UI.Xaml.Controls.StackPanel.ControlsEnable方法的典型用法代码示例。如果您正苦于以下问题:C# StackPanel.ControlsEnable方法的具体用法?C# StackPanel.ControlsEnable怎么用?C# StackPanel.ControlsEnable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows.UI.Xaml.Controls.StackPanel的用法示例。


在下文中一共展示了StackPanel.ControlsEnable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SendCommand_Tapped

        private void SendCommand_Tapped(object sender, TappedRoutedEventArgs e)
        {
            Flyout flyOut = new Flyout();
            flyOut.Placement = FlyoutPlacementMode.Top;

            flyOut.FlyoutPresenterStyle = new Style(typeof(FlyoutPresenter));
            flyOut.FlyoutPresenterStyle.Setters.Add(new Setter(FlyoutPresenter.RequestedThemeProperty, ElementTheme.Dark));
            flyOut.FlyoutPresenterStyle.Setters.Add(new Setter(FlyoutPresenter.PaddingProperty, 10));
            
            StackPanel panel = new StackPanel();
            panel.Width = 300;
            panel.Margin = new Thickness(10);
            panel.Orientation = Orientation.Vertical;
            panel.Children.Add(new TextBlock() { Text = "Command name", FontSize = 14.8 });
            TextBox commandName = new TextBox();
            panel.Children.Add(commandName);
            panel.Children.Add(new TextBlock() { Text = "Params", FontSize = 14.8, Margin = new Thickness(0, 10, 0, 0) });
            TextBox commandParams = new TextBox();
            panel.Children.Add(commandParams);
            panel.Children.Add(new TextBlock() { Text = "JSON or empty string" });
            Button sendButton = new Button() { Content = "Send", Margin = new Thickness(0, 10, 0, 0) };
            panel.Children.Add(sendButton);

            if (CommandSelected != null)
            {
                commandName.Text = CommandSelected.Name;
                commandParams.Text = (string)new ObjectToJsonStringConverter().Convert(CommandSelected.Parameters, null, null, null);
            }

            sendButton.Command = new DelegateCommand(async () =>
            {
                if (commandName.Text.Trim() == "")
                {
                    new MessageDialog("Empty command name", "Send command").ShowAsync();
                    return;
                }
                panel.ControlsEnable(false);
                LoadingItems++;
                try
                {
                    var command = new Command(commandName.Text, commandParams.Text != "" ? JObject.Parse(commandParams.Text) : null);
                    Debug.WriteLine("CMD SEND START");
                    await ClientService.Current.SendCommandAsync(deviceId, command, CommandResultCallback);
                    Debug.WriteLine("CMD SEND END");
                    flyOut.Hide();
                }
                catch (Exception ex)
                {
                    new MessageDialog(ex.Message, "Send command").ShowAsync();
                }
                panel.ControlsEnable(true);
                LoadingItems--;
            });

            flyOut.Content = panel;
            flyOut.ShowAt((FrameworkElement)sender);
        }
开发者ID:devicehive,项目名称:devicehive-.net,代码行数:57,代码来源:DevicePage.xaml.cs

示例2: SendCommand_Tapped

        private void SendCommand_Tapped(object sender, TappedRoutedEventArgs e)
        {
            Flyout flyOut = new Flyout();
            flyOut.Width = 300;
            flyOut.PlacementTarget = sender as UIElement;
            flyOut.Placement = PlacementMode.Top;
            flyOut.Background = new SolidColorBrush(Colors.Black);

            StackPanel panel = new StackPanel();
            panel.Margin = new Thickness(10);
            panel.Orientation = Orientation.Vertical;
            panel.Children.Add(new TextBlock() { Text = "Command name", FontSize = 14.8 });
            TextBox commandName = new TextBox();
            panel.Children.Add(commandName);
            panel.Children.Add(new TextBlock() { Text = "Params", FontSize = 14.8, Margin = new Thickness(0, 10, 0, 0) });
            TextBox commandParams = new TextBox();
            panel.Children.Add(commandParams);
            panel.Children.Add(new TextBlock() { Text = "JSON or empty string" });
            Button sendButton = new Button() { Content = "Send", Margin = new Thickness(0, 10, 0, 0) };
            panel.Children.Add(sendButton);

            if (CommandSelected != null)
            {
                commandName.Text = CommandSelected.Name;
                commandParams.Text = (string)new ObjectToJsonStringConverter().Convert(CommandSelected.Parameters, null, null, null);
            }

            sendButton.Command = new DelegateCommand(async () =>
            {
                if (commandName.Text.Trim() == "")
                {
                    new MessageDialog("Empty command name", "Send command").ShowAsync();
                    return;
                }
                panel.ControlsEnable(false);
                LoadingItems++;
                try
                {
                    var command = new Command(commandName.Text, JObject.Parse(commandParams.Text));
                    StopPollCommandResult();
                    Debug.WriteLine("CMD SEND START");
                    var commandSent = await ClientService.Current.SendCommandAsync(deviceId, command);
                    Debug.WriteLine("CMD SEND END");
                    StartPollCommandResult((int)commandSent.Id);
                    flyOut.IsOpen = false;
                }
                catch (Exception ex)
                {
                    new MessageDialog(ex.Message, "Send command").ShowAsync();
                }
                panel.ControlsEnable(true);
                LoadingItems--;
            });

            flyOut.Content = panel;
            flyOut.IsOpen = true;
        }
开发者ID:oryol,项目名称:devicehive-.net,代码行数:57,代码来源:DevicePage.xaml.cs


注:本文中的Windows.UI.Xaml.Controls.StackPanel.ControlsEnable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。