本文整理汇总了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);
}
示例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);
}
}
示例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;
}
//.........这里部分代码省略.........