當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。