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


C# TextBox.ClearValue方法代码示例

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


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

示例1: SetText2

        public void SetText2 ()
        {
            TextBox box = new TextBox { Text = "Blah" };
            Assert.AreEqual ("Blah", box.GetValue (TextBox.TextProperty), "#1");
            box.SetValue (TextBox.TextProperty, null);
            Assert.AreEqual ("", box.GetValue (TextBox.TextProperty), "#2");
	    box.Text = "o hi";
            box.ClearValue (TextBox.TextProperty);
            Assert.AreEqual ("", box.GetValue (TextBox.TextProperty), "#3");
        }
开发者ID:snorp,项目名称:moon,代码行数:10,代码来源:TextBoxTest.cs

示例2: ClearingTheAttachedPropertyRemovesTheValidationRule

        public void ClearingTheAttachedPropertyRemovesTheValidationRule()
        {
            var textBox = new TextBox();
            textBox.BeginInit();
            var binding = new Binding("ValidatedStringProperty")
            {
                Mode = BindingMode.OneWayToSource,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            };
            BindingOperations.SetBinding(textBox, TextBox.TextProperty, binding);
            textBox.EndInit();

            Validate.SetBindingForProperty(textBox, "Text");

            Assert.AreEqual(1, binding.ValidationRules.OfType<ValidatorRule>().Count());

            textBox.ClearValue(Validate.BindingForPropertyProperty);

            Assert.AreEqual(0, binding.ValidationRules.OfType<ValidatorRule>().Count());
        }
开发者ID:HondaBey,项目名称:EnterpriseLibrary6,代码行数:20,代码来源:ValidatorRuleAttachmentFixture.cs

示例3: RenderEditItemField


//.........这里部分代码省略.........
                    TimePicker timePicker = new TimePicker() { DataContext = container, MinWidth = minWidth, IsTabStop = true };
                    // set up two-way data binding so that we don't have to pick up the new value in the event handler
                    timePicker.SetBinding(TimePicker.ValueProperty, new Binding(pi.Name) { Mode = BindingMode.TwoWay });
                    timePicker.ValueChanged += new EventHandler<DateTimeValueChangedEventArgs>(delegate
                    {
                        folder.NotifyPropertyChanged("FirstDue");
                        folder.NotifyPropertyChanged("FirstDueColor");
                    });
                    timePicker.TabIndex = tabIndex++;
                    EditStackPanel.Children.Add(timePicker);
                    break;
                case DisplayTypes.Checkbox:
                    CheckBox cb = new CheckBox() { DataContext = container, IsTabStop = true };
                    cb.SetBinding(CheckBox.IsCheckedProperty, new Binding(pi.Name) { Mode = BindingMode.TwoWay });
                    cb.TabIndex = tabIndex++;
                    EditStackPanel.Children.Add(cb);
                    break;
                case DisplayTypes.TagList:
                    TextBox taglist = new TextBox() { MinWidth = minWidth, IsTabStop = true };
                    taglist.KeyUp += new KeyEventHandler(TextBox_KeyUp);
                    taglist.TabIndex = tabIndex++;
                    RenderEditItemTagList(taglist, (Item) container, pi);
                    EditStackPanel.Children.Add(taglist);
                    break;
                case DisplayTypes.ImageUrl:
                    // TODO: wire up to picture picker, and upload to an image service
                    break;
                case DisplayTypes.LinkArray:
                    tb.InputScope = new InputScope() { Names = { new InputScopeName() { NameValue = InputScopeNameValue.Url } } };
                    tb.AcceptsReturn = true;
                    tb.TextWrapping = TextWrapping.Wrap;
                    tb.Height = 150;
                    tb.TabIndex = tabIndex++;
                    tb.ClearValue(TextBox.TextProperty);
                    if (!String.IsNullOrEmpty((string) currentValue))
                    {
                        try
                        {
                            var linkList = JsonConvert.DeserializeObject<List<Link>>((string)currentValue);
                            tb.Text = String.Concat(linkList.Select(l => l.Name != null ? l.Name + "," + l.Url + "\n" : l.Url + "\n").ToList());
                        }
                        catch (Exception)
                        {
                        }
                    }
                    tb.LostFocus += new RoutedEventHandler(delegate
                    {
                        // the expected format is a newline-delimited list of Name, Url pairs
                        var linkArray = tb.Text.Split(new char[] { '\r','\n' }, StringSplitOptions.RemoveEmptyEntries);
                        var linkList = new List<Link>();
                        foreach (var link in linkArray)
                        {
                            var nameval = link.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                            if (nameval.Length == 0)
                                continue;
                            if (nameval.Length == 1)
                                linkList.Add(new Link() { Url = nameval[0].Trim() });
                            else
                                linkList.Add(new Link() { Name = nameval[0].Trim(), Url = nameval[1].Trim() });
                        }
                        var json = JsonConvert.SerializeObject(linkList);
                        pi.SetValue(container, json, null);
                    });
                    EditStackPanel.Children.Add(tb);
                    break;
                case DisplayTypes.Hidden:
开发者ID:ogazitt,项目名称:zaplify,代码行数:67,代码来源:ItemPage.xaml.cs

示例4: clearTextBox

 private void clearTextBox(TextBox text)
 {
     if (text.Text != String.Empty) text.ClearValue(TextBox.TextProperty);
 }
开发者ID:sherlok901,项目名称:quizApp,代码行数:4,代码来源:Emulator-05M.xaml.cs


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