Пример #1
0
        internal void Initialize(TagsTextBoxFooter inline)
        {
            InputPlaceholder              = inline;
            InputPlaceholder.TextChanged += OnTextChanged;

            ItemsWrapPanel = (TagsWrapPanel)ItemsPanelRoot;

            InputPlaceholder.KeyDown     += OnKeyDown;
            ItemsWrapPanel.LayoutUpdated += OnWrapLayoutUpdated;

            var bindPlaceholder = new Binding();

            bindPlaceholder.Path   = new PropertyPath("PlaceholderText");
            bindPlaceholder.Source = this;

            var bindCanShow = new Binding();

            bindCanShow.Path   = new PropertyPath("CanShowPlaceholder");
            bindCanShow.Source = this;

            //var bindText = new Binding();
            //bindText.Path = new PropertyPath("Text");
            //bindText.Source = InputPlaceholder;
            //bindText.Mode = BindingMode.TwoWay;

            InputPlaceholder.SetBinding(TextBox.PlaceholderTextProperty, bindPlaceholder);
            InputPlaceholder.SetBinding(TagsTextBoxFooter.CanShowPlaceholderProperty, bindCanShow);

            //SetBinding(TextProperty, bindText);
        }
Пример #2
0
        private static void OnItemHeightOrWidthPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            TagsWrapPanel source = (TagsWrapPanel)d;
            double value = (double)e.NewValue;

            // Ignore the change if requested
            if (source._ignorePropertyChange)
            {
                source._ignorePropertyChange = false;
                return;
            }

            // Validate the length (which must either be NaN or a positive,
            // finite number)
            if (!value.IsNaN() && ((value <= 0.0) || double.IsPositiveInfinity(value)))
            {
                // Reset the property to its original state before throwing
                source._ignorePropertyChange = true;
                source.SetValue(e.Property, (double)e.OldValue);

                string message = string.Format(
                    CultureInfo.InvariantCulture,
                    "WrapPanel_OnItemHeightOrWidthPropertyChanged_InvalidValue",
                    value);
                throw new ArgumentException(message, "value");
            }

            // The length properties affect measuring.
            source.InvalidateMeasure();
        }