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