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


C# TextBox.SetBinding方法代码示例

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


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

示例1: CreateCustomTextBox

        /// <summary>
        /// Creates a textbox to allow input of custom values for custom type RadialMenuButtons
        /// </summary>
        private void CreateCustomTextBox()
        {
            CustomTextBox = new TextBox
            {
                Name = "CustomTextBox",
                FontSize = LabelSize,
                Margin = new Thickness(0, 67, 0, 0),
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                BorderThickness = new Thickness(0),
                TextAlignment = TextAlignment.Center,
                Background = new SolidColorBrush(Colors.Transparent),
                AcceptsReturn = false,
                Style = (Style)this.Resources["TransparentTextBox"]
            };

            CustomTextBox.Padding = new Thickness(0);

            CustomTextBox.GotFocus += (sender, args) => LabelTextElement.Opacity = 0;
            CustomTextBox.LostFocus += (sender, args) =>
            {
                OriginalRadialMenuButton.Value = ((TextBox)sender).Text;
                LabelTextElement.Opacity = 1;
                OriginalRadialMenuButton.OnValueChanged(args);

            };
            CustomTextBox.SetBinding(TextBox.TextProperty, new Windows.UI.Xaml.Data.Binding() { Source = this.CustomValue });

            TextLabelGrid.Children.Add(CustomTextBox);
        }
开发者ID:CatalystCode,项目名称:radial-menu,代码行数:33,代码来源:PieSlice.xaml.cs

示例2: ComboBox_SelectionChanged

        private void ComboBox_SelectionChanged(object sender,
            SelectionChangedEventArgs e)
        {
            Service currentService
                = ServicesComboBox.SelectedItem as Service;

            metricDetails.Children.Clear();

            foreach (string item in currentService.Properties.Keys)
            {
                var textBlock = new TextBlock();
                textBlock.Text = item;
                textBlock.Style = App.Current.Resources["TitleTextStyle"] as Style;
                textBlock.Margin = new Thickness(0, 16, 0, 0);
                metricDetails.Children.Add(textBlock);

                var textBox = new TextBox();
                textBox.Foreground = new SolidColorBrush(Colors.Black);
                textBox.Margin = new Thickness(0, 8, 0, 0);

                Binding binding = new Binding();
                binding.Path = new PropertyPath("Content");
                binding.Source = currentService.Properties[item];
                binding.Mode = BindingMode.TwoWay;
                textBox.SetBinding(TextBox.TextProperty, binding);
                metricDetails.Children.Add(textBox);
            }
        }
开发者ID:rlbisbe,项目名称:metrics,代码行数:28,代码来源:AddWidget.xaml.cs

示例3: BuildControl

        private void BuildControl(InputType type, string label, string placeholderText, double labelFontSize, double labelTranslateY, string groupName, ContentControl ccInput) {

            FrameworkElement fe = null;

            if (type == InputType.text)
            {
                _udfTB1 = new TextBox();
                _udfTB1.PlaceholderText = placeholderText;
                _udfTB1.Style = _GeneralTextBoxStyle;
                _udfTB1.SetBinding(TextBox.DataContextProperty, new Binding() { Path= new PropertyPath("{x:Null}") });
                _udfTB1.SetBinding(TextBox.TextProperty, new Binding() { Source = Value });
                _udfTB1.KeyUp += ittext_KeyUp;

                _udfg1 = new Grid() { Padding = new Thickness(2, 2, 2, 2), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment= VerticalAlignment.Top};
                _udfTBL1 = new TextBlock();
                _udfTBL1.Text = label;
                _udfTBL1.FontSize = labelFontSize;
                _udfg1.Margin = new Thickness(0, labelTranslateY, 0, 0);
                _udfg1.Visibility = Visibility.Collapsed;
                _udfg1.Children.Add(_udfTBL1);
                
                var gd = new Grid();
                gd.Children.Add(_udfg1);
                gd.Children.Add(_udfTB1);

                fe = gd;
            }
            else if (type == InputType.password)
            {
                _udfPB1 = new PasswordBox();
                _udfPB1.PlaceholderText = placeholderText;
                _udfPB1.Style = _GeneralPasswordBoxStyle;
                _udfPB1.PasswordChanged += itpassword_PasswordChanged;

                _udfg1 = new Grid() { Padding = new Thickness(2, 2, 2, 2), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top };
                _udfTBL1 = new TextBlock();
                _udfTBL1.Text = label;
                _udfTBL1.FontSize = labelFontSize;
                _udfg1.Margin = new Thickness(0, labelTranslateY, 0, 0);
                _udfg1.Visibility = Visibility.Collapsed;
                _udfg1.Children.Add(_udfTBL1);

                var gd = new Grid();
                gd.Children.Add(_udfg1);
                gd.Children.Add(_udfPB1);

                fe = gd;
            }
            else if (type == InputType.combobox)
            {
                _udfCB1 = new ComboBox();
                _udfCB1.Style = _GeneralComboBoxStyle;
                _udfCB1.PlaceholderText = placeholderText;
                _udfCB1.SetBinding(ComboBox.ItemsSourceProperty, new Binding() { Source = Items });
                _udfCB1.Width = this.Width;
                _udfCB1.SelectionChanged += itcombobox_SelectionChanged;

                _udfg1 = new Grid() { Padding = new Thickness(2, 2, 2, 2), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top };
                _udfTBL1 = new TextBlock();
                _udfTBL1.Text = label;
                _udfTBL1.FontSize = labelFontSize;
                _udfg1.Margin = new Thickness(0, labelTranslateY, 0, 0);
                _udfg1.Visibility = Visibility.Collapsed;
                _udfg1.Children.Add(_udfTBL1);

                var gd = new Grid();
                gd.Children.Add(_udfg1);
                gd.Children.Add(_udfCB1);

                fe = gd;
            }
            else if (type == InputType.checkbox)
            {
                var sp = new StackPanel();
                sp.Orientation = Orientation.Horizontal;
                
                var lb = new TextBlock();
                lb.Text = label;
                lb.FontSize = LabelFontSize;
                lb.Margin = new Thickness(0, LabelTranslateY, 0, 0);

                _udfChkB1 = new CheckBox();
                _udfChkB1.Checked += itcheckbox_Changed;
                _udfChkB1.Unchecked += itcheckbox_Changed;
                _udfChkB1.Content = lb;
                _udfChkB1.Style = _GeneralCheckBoxStyle;
                sp.Children.Add(_udfChkB1);

                fe = sp;
            }
            else if (type == InputType.toggleButton)
            {
                _udfTBut1 = new ToggleButton();
                _udfTBut1.Style = _GeneralToggleButtonStyle;
                _udfTBut1.Checked += ittogglebutton_changed;
                _udfTBut1.Unchecked += ittogglebutton_changed;
                _udfTBut1.FontSize = FontSize;
                _udfTBut1.Content = Content1;
                fe = _udfTBut1;
            }
//.........这里部分代码省略.........
开发者ID:liquidboy,项目名称:X,代码行数:101,代码来源:Input.cs


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