本文整理汇总了C#中System.Windows.Controls.TextBox.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# TextBox.SetValue方法的具体用法?C# TextBox.SetValue怎么用?C# TextBox.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.TextBox
的用法示例。
在下文中一共展示了TextBox.SetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenereateFields
public static void GenereateFields()
{
// Get the Grid from the MainWindow
Grid AuthenticationGrid = ((MainWindow)System.Windows.Application.Current.MainWindow).AuthenticationGrid;
// Build a list of Digest Auth Fields
List<string> fields = new List<string>();
fields.Add("Username");
fields.Add("Password");
for (int i = 0; i < fields.Count; i++)
{
// Add a row to the AuthGrid
RowDefinition rowDefinition = new RowDefinition();
rowDefinition.Height = GridLength.Auto;
AuthenticationGrid.RowDefinitions.Add(rowDefinition);
// Add a Label
Label label = new Label();
label.SetValue(Grid.RowProperty, i + 1);
label.SetValue(Grid.ColumnProperty, 0);
label.Name = "AuthenticationKey" + i;
label.Content = fields[i] + ":";
AuthenticationGrid.Children.Add(label);
// Add a textbox
TextBox textBox = new TextBox();
textBox.SetValue(Grid.RowProperty, i + 1);
textBox.SetValue(Grid.ColumnProperty, 1);
textBox.Name = "AuthenticationValue" + i;
AuthenticationGrid.Children.Add(textBox);
}
}
示例2: fachpicker_SelectionChanged
private void fachpicker_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Fach f = fachpicker.SelectedItem as Fach;
if (f.lektion == Lektion.Anderes && f.customfach == null)
{
if (fächeradded) { }
else
{
//benutzerdefiniertes Fach
fächer = new TextBlock() { Text = "Fach: ", FontSize = 34, Margin = new Thickness(7,0,0,0) };
fächer.SetValue(Grid.RowProperty, 1);
fächer2 = new TextBox();
fächer2.SetValue(Grid.RowProperty, 1);
fächer2.SetValue(Grid.ColumnProperty, 1);
ContentPanel.Children.Add(fächer);
ContentPanel.Children.Add(fächer2);
fächeradded = true;
}
}
else
{
Lehrperson.Text = f.Lehrer;
Farbe.SelectedIndex = f.color;
if (fächeradded)
{
ContentPanel.Children.Remove(fächer);
ContentPanel.Children.Remove(fächer2);
fächeradded = false;
}
}
}
示例3: MainWindow
public MainWindow()
{
MemoryStream iconstream = new MemoryStream();
Properties.Resources.sudokusolver.Save(iconstream);
iconstream.Seek(0, SeekOrigin.Begin);
this.Icon = System.Windows.Media.Imaging.BitmapFrame.Create(iconstream);
InitializeComponent();
DataContext = new SudokuGrid();
foreach (var square in (DataContext as SudokuGrid).Squares)
{
TextBox sudokuSquare = new TextBox();
sudokuSquare.DataContext = square;
sudokuSquare.SetBinding(TextBox.TextProperty, new Binding("Value") { Converter = new StringToNullableIntConverter(), Mode = BindingMode.TwoWay });
sudokuSquare.Width = 25;
sudokuSquare.FontFamily = new System.Windows.Media.FontFamily("Tahoma");
sudokuSquare.FontSize = 14;
sudokuGrid.Children.Add(sudokuSquare);
sudokuSquare.SetValue(Grid.RowProperty, square.Row);
sudokuSquare.SetValue(Grid.ColumnProperty, square.Column);
double bottomThickness = (square.Row == 2 || square.Row == 5) ? 2 : 0;
double rightThickness = (square.Column == 2 || square.Column == 5) ? 2 : 0;
sudokuSquare.Margin = new Thickness(0, 0, rightThickness, bottomThickness);
sudokuSquare.SetBinding(TextBox.ToolTipProperty, "PossibleValuesString");
}
}
示例4: OnNavigatedTo
// Executes when the user navigates to this page.
protected override void OnNavigatedTo(NavigationEventArgs e)
{
var rows = myGrid.RowDefinitions.Count;
var columns = myGrid.ColumnDefinitions.Count;
for (int r = 0; r < rows; r++)
{
for (int c = 0; c < columns; c++)
{
var tb = new TextBox();
tb.Text = string.Format("{0}:{1}", r, c);
tb.Margin = new Thickness(10);
tb.SetValue(Grid.ColumnProperty, c);
tb.SetValue(Grid.RowProperty, r);
tb.GotFocus += (s,ev) =>
{
var textbox = (TextBox) s;
var currentColor = (SolidColorBrush) textbox.Background;
textbox.Background =
currentColor.Color == Colors.White ?
new SolidColorBrush(Colors.Green) :
new SolidColorBrush(Colors.White);
};
myGrid.Children.Add(tb);
}
}
}
示例5: CreateChannelValue
private UIElement CreateChannelValue(int i)
{
TextBox result = new TextBox();
result.SetValue(Grid.RowProperty, i);
result.SetValue(Grid.ColumnProperty, 1);
result.TextChanged += (sender, args) =>
{
ChannelValueChanged?.Invoke(this, new ChannelValueChangedEventArgs());
};
return result;
}
示例6: AddNewRow
public void AddNewRow(int Row, string Caption)
{
System.Windows.Controls.TextBlock tb = new TextBlock();
tb.SetValue(Grid.RowProperty,Row);
tb.SetValue(Grid.ColumnProperty,0);
tb.Text = Caption;
System.Windows.Controls.TextBox txtbx = new TextBox();
txtbx.SetValue(Grid.RowProperty,Row);
txtbx.SetValue(Grid.ColumnProperty,1);
ControlGrid.Children.Add(tb);
ControlGrid.Children.Add(txtbx);
}
示例7: SetMask
public static void SetMask(TextBox textBox, string mask)
{
if (textBox == null)
throw new ArgumentNullException("textBox");
textBox.SetValue(MaskProperty, mask);
}
示例8: AddUI
public override void AddUI(Grid grid)
{
if (Config != null && Config.ShownAtRunTime)
{
grid.RowDefinitions.Add(new RowDefinition());
#region
StackPanel g = new StackPanel() { Orientation = System.Windows.Controls.Orientation.Horizontal, Margin=new Thickness(5,0,0,0) };
TextBlock lblUrl = new TextBlock() { VerticalAlignment = System.Windows.VerticalAlignment.Center, Margin = new Thickness(2) };
lblUrl.Text = Resources.Strings.LabelUrl;
g.Children.Add(lblUrl);
TextBox tbFormat = new TextBox() { Margin = new Thickness(4,2,0,2), Width = 50, MaxWidth= 60 };
TextBox tb = new TextBox() {
Margin = new Thickness(2),
HorizontalAlignment = HorizontalAlignment.Stretch
};
tb.SetValue(ToolTipService.ToolTipProperty, Config.ToolTip);
if (value != null)
tb.Text = value.Url.ToString();
tb.TextChanged += (s, e) =>
{
if (value == null)
Value = new GPRasterData(Config.Name, tb.Text, tbFormat.Text) { Format = tbFormat.Text };//Workaround for slapi bug
else
value.Url = tb.Text;
RaiseCanExecuteChanged();
};
g.Children.Add(tb);
TextBlock lbl = new TextBlock() { VerticalAlignment = System.Windows.VerticalAlignment.Center, Margin = new Thickness(2) };
lbl.Text = Resources.Strings.LabelFormat;
g.Children.Add(lbl);
if (Config is RasterDataParameterConfig)
tbFormat.SetValue(ToolTipService.ToolTipProperty, (Config as RasterDataParameterConfig).FormatToolTip);
if (value != null)
tbFormat.Text = value.Format.ToString();
tbFormat.TextChanged += (s, e) =>
{
if (value == null)
Value = new GPRasterData(Config.Name, tb.Text, tbFormat.Text) { Format = tbFormat.Text };//Workaround for slapi bug
else
value.Format = tbFormat.Text;
RaiseCanExecuteChanged();
};
g.Children.Add(tbFormat);
g.SetValue(Grid.RowProperty, grid.RowDefinitions.Count - 1);
g.SetValue(Grid.ColumnProperty, 0);
g.SetValue(Grid.ColumnSpanProperty, 2);
grid.Children.Add(g);
RaiseCanExecuteChanged();
#endregion
}
}
示例9: TextboxHintTextExtension
public TextboxHintTextExtension(TextBox textbox, string hintText)
: base(textbox)
{
textbox.GotFocus += TextboxGotFocus;
textbox.LostFocus += TextboxLostFocus;
textbox.TextChanged += TextboxContentChanged;
if (!string.IsNullOrEmpty(hintText))
textbox.SetValue(TextProperty, hintText);
}
示例10: SetAlwaysScrollToEnd
public static void SetAlwaysScrollToEnd(TextBox textBox, bool alwaysScrollToEnd)
{
if (textBox == null)
{
throw new ArgumentNullException("textBox");
}
textBox.SetValue(AlwaysScrollToEndProperty, alwaysScrollToEnd);
}
示例11: SetCommand
public static void SetCommand(TextBox textBox, ICommand command)
{
if (textBox == null)
{
throw new ArgumentNullException("textBox");
}
textBox.SetValue(CommandProperty, command);
}
示例12: SetDefaultTextAfterCommandExecution
public static void SetDefaultTextAfterCommandExecution(TextBox textBox, string defaultText)
{
if (textBox == null)
{
throw new ArgumentNullException("textBox");
}
textBox.SetValue(DefaultTextAfterCommandExecutionProperty, defaultText);
}
示例13: GetOrCreateBehavior
private static TextBoxTextChangedCommandBehavior GetOrCreateBehavior(TextBox textBox)
{
TextBoxTextChangedCommandBehavior behavior = textBox.GetValue(TextChangedCommandBehaviorProperty) as TextBoxTextChangedCommandBehavior;
if (behavior == null)
{
behavior = new TextBoxTextChangedCommandBehavior(textBox);
textBox.SetValue(TextChangedCommandBehaviorProperty, behavior);
}
return behavior;
}
示例14: GuideDataGrid_SelectionChanged
private void GuideDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (GuideDataGrid.SelectedItem == null)
{
//avoid Exception
return;
}
string sp_guide_id = ((DataRowView)GuideDataGrid.SelectedItem).Row["id"].ToString();
Task<DataTable> task = new Task<DataTable>(() =>
{
string sql = @"SELECT * FROM unit_talk_master WHERE id={0}";
return DAL.GetDataTable(String.Format(sql, sp_guide_id));
});
task.ContinueWith(t =>
{
if (t.Exception != null)
{
Utility.ShowException(t.Exception);
return;
}
if (t.Result == null || t.Result.Rows.Count == 0)
{
return;
}
DataRow guideData = t.Result.Rows[0];
GuideTalk.Children.Clear();
for (int i = 0; i < 128; i++)
{
string guide = guideData[i + 6].ToString(); //remove id&5 icon
if (!string.IsNullOrWhiteSpace(guide))
{
Grid grid = new Grid();
grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
grid.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto });
var tbName = new TextBlock()
{
Text = Utility.ParseMessageName(i),
Background = (SolidColorBrush)Application.Current.Resources["DefaultBrush"]
};
var tbValue = new TextBox()
{
Text = guide.Replace("*", "\n"),
IsReadOnly = true
};
grid.Children.Add(tbName);
grid.Children.Add(tbValue);
tbName.SetValue(Grid.RowProperty, 0);
tbValue.SetValue(Grid.RowProperty, 1);
GuideTalk.Children.Add(grid);
}
}
}, MainWindow.UiTaskScheduler);
task.Start();
}
示例15: GetOrCreateBehavior
private static ReturnCommandBehavior GetOrCreateBehavior(TextBox textBox)
{
ReturnCommandBehavior behavior = textBox.GetValue(ReturnCommandBehaviorProperty) as ReturnCommandBehavior;
if (behavior == null)
{
behavior = new ReturnCommandBehavior(textBox);
textBox.SetValue(ReturnCommandBehaviorProperty, behavior);
}
return behavior;
}