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


C# TextBox.SetValue方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:MattGong,项目名称:RESTful,代码行数:33,代码来源:BasicAuth.cs

示例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;
         }
     }
 }
开发者ID:famoser,项目名称:Gymoberwil,代码行数:31,代码来源:Fachbearbeiten.xaml.cs

示例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");
     }
 }
开发者ID:Mellen,项目名称:SudokuSolver,代码行数:25,代码来源:MainWindow.xaml.cs

示例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);
                }
            }
        }
开发者ID:stiano,项目名称:sl4,代码行数:33,代码来源:GridForm.xaml.cs

示例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;
        }
开发者ID:EFanZh,项目名称:EFanZh,代码行数:13,代码来源:ChannelValuesController.cs

示例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);
        }
开发者ID:GeoffEngelstein,项目名称:WW6-WPF,代码行数:14,代码来源:CustomFieldEntry.xaml.cs

示例7: SetMask

        public static void SetMask(TextBox textBox, string mask)
        {
            if (textBox == null)
                throw new ArgumentNullException("textBox");

            textBox.SetValue(MaskProperty, mask);
        }
开发者ID:baughj,项目名称:Spark,代码行数:7,代码来源:InputMasking.cs

示例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
            }
        }
开发者ID:yulifengwx,项目名称:arcgis-viewer-silverlight,代码行数:57,代码来源:RasterParameter.cs

示例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);
 }
开发者ID:barbarossia,项目名称:CWF,代码行数:9,代码来源:TextboxHintTextExtension.cs

示例10: SetAlwaysScrollToEnd

        public static void SetAlwaysScrollToEnd(TextBox textBox, bool alwaysScrollToEnd)
        {
            if (textBox == null)
            {
                throw new ArgumentNullException("textBox");
            }

            textBox.SetValue(AlwaysScrollToEndProperty, alwaysScrollToEnd);
        }
开发者ID:RipleyBooya,项目名称:SyncTrayzor,代码行数:9,代码来源:TextBoxUtilities.cs

示例11: SetCommand

        public static void SetCommand(TextBox textBox, ICommand command)
        {
            if (textBox == null)
            {
                throw new ArgumentNullException("textBox");
            }

            textBox.SetValue(CommandProperty, command);
        }
开发者ID:sgh1986915,项目名称:Sliverlight-Prism,代码行数:9,代码来源:ReturnKey.cs

示例12: SetDefaultTextAfterCommandExecution

        public static void SetDefaultTextAfterCommandExecution(TextBox textBox, string defaultText)
        {
            if (textBox == null)
            {
                throw new ArgumentNullException("textBox");
            }

            textBox.SetValue(DefaultTextAfterCommandExecutionProperty, defaultText);
        }
开发者ID:sgh1986915,项目名称:Sliverlight-Prism,代码行数:9,代码来源:ReturnKey.cs

示例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;
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:11,代码来源:TextChanged.cs

示例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();
 }
开发者ID:WindWT,项目名称:RTDDE.Executer,代码行数:54,代码来源:Guide.xaml.cs

示例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;
        }
开发者ID:JohnDMathis,项目名称:Pippin,代码行数:11,代码来源:ReturnKey.cs


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