public override void OnApplyTemplate()
#endif
        {
            base.OnApplyTemplate();

            if (InputBox != null)
            {
#if WINDOWS_STORE || WINDOWS_PHONE_APP
                var binding = new Windows.UI.Xaml.Data.Binding();
#elif WINDOWS_PHONE
                var binding = new System.Windows.Data.Binding();
#endif

                binding.Source = InputBox;
                binding.Path   = new PropertyPath("Text");

                SetBinding(ValueProperty, binding);

                TextBinding.SetUpdateSourceOnChange(InputBox, true);
                InputBox.TextChanged      -= InputBoxTextChanged;
                InputBox.SelectionChanged -= InputBoxSelectionChanged;

                // manually adding
                // GetBindingExpression doesn't seem to respect TemplateBinding
                // so TextBoxBinding's code doesn't fire

                InputBox.TextChanged      += InputBoxTextChanged;
                InputBox.SelectionChanged += InputBoxSelectionChanged;
            }
        }
Ejemplo n.º 2
0
		public override async void OnApplyTemplate()
#endif
        {
            base.OnApplyTemplate();

            InputBox = GetTemplateChild(InputBoxName) as TextBox;

            if (InputBox != null)
            {
                // manually adding
                // GetBindingExpression doesn't seem to respect TemplateBinding
                // so TextBoxBinding's code doesn't fire

#if WINDOWS_STORE || WINDOWS_PHONE_APP
                var binding = new Windows.UI.Xaml.Data.Binding();
#elif WINDOWS_PHONE
			    var binding = new System.Windows.Data.Binding();
#endif

                binding.Source = InputBox;
                binding.Path = new PropertyPath("Text");

                SetBinding(ValueProperty, binding);

                TextBinding.SetUpdateSourceOnChange(InputBox, true);
                
                HookUpEventForIsSubmitOnEnterKey();

				if (!ApplicationSpace.IsDesignMode)
	                await DelayInputSelect();
            }
        }
Ejemplo n.º 3
0
        public override void SubscribeToEvents()
        {
            var frameworkElement = Target as FrameworkElement;

            if (frameworkElement == null)
            {
                return;
            }

#if WINDOWS_WPF
            var listenerBinding = new System.Windows.Data.Binding(_targetName)
            {
                Source = frameworkElement
            };
#endif
#if WINDOWS_COMMON
            var listenerBinding = new Windows.UI.Xaml.Data.Binding()
            {
                Path   = new PropertyPath(_targetName),
                Source = frameworkElement
            };
#endif
            var attachedProperty = DependencyProperty.RegisterAttached(
                "ListenAttached" + _targetName + Guid.NewGuid().ToString("N")
                , typeof(object)
                , typeof(FrameworkElement)
                , new PropertyMetadata(null, (s, e) => FireValueChanged(e.NewValue)));
            frameworkElement.SetBinding(attachedProperty, listenerBinding);
        }
Ejemplo n.º 4
0
        public override async void OnApplyTemplate()
#endif
        {
            base.OnApplyTemplate();

            InputBox = GetTemplateChild(InputBoxName) as TextBox;

            if (InputBox != null)
            {
                // manually adding
                // GetBindingExpression doesn't seem to respect TemplateBinding
                // so TextBoxBinding's code doesn't fire

#if WINDOWS_STORE || WINDOWS_PHONE_APP
                var binding = new Windows.UI.Xaml.Data.Binding();
#elif WINDOWS_PHONE
                var binding = new System.Windows.Data.Binding();
#endif

                binding.Source = InputBox;
                binding.Path   = new PropertyPath("Text");

                SetBinding(ValueProperty, binding);

                TextBinding.SetUpdateSourceOnChange(InputBox, true);

                HookUpEventForIsSubmitOnEnterKey();

                if (!ApplicationSpace.IsDesignMode)
                {
                    await DelayInputSelect();
                }
            }
        }
		public override void OnApplyTemplate()
#endif
        {
            base.OnApplyTemplate();
            
            if (InputBox != null)
			{
#if WINDOWS_STORE || WINDOWS_PHONE_APP
                var binding = new Windows.UI.Xaml.Data.Binding();
#elif WINDOWS_PHONE
			    var binding = new System.Windows.Data.Binding();
#endif

                binding.Source = InputBox;
                binding.Path = new PropertyPath("Text");

                SetBinding(ValueProperty, binding);

                TextBinding.SetUpdateSourceOnChange(InputBox, true);
				InputBox.TextChanged -= InputBoxTextChanged;
				InputBox.SelectionChanged -= InputBoxSelectionChanged;

                // manually adding
                // GetBindingExpression doesn't seem to respect TemplateBinding
                // so TextBoxBinding's code doesn't fire

                InputBox.TextChanged += InputBoxTextChanged;
				InputBox.SelectionChanged += InputBoxSelectionChanged;
            }
        }
Ejemplo n.º 6
0
        public static void SetForeground(this FrameworkElement element, WBinding binding)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            element.SetBinding(GetForegroundProperty(element), binding);
        }
Ejemplo n.º 7
0
        public static object GetForegroundCache(this FrameworkElement element)
        {
            WBinding binding = GetForegroundBinding(element);

            if (binding != null)
            {
                return(binding);
            }

            return(GetForeground(element));
        }
Ejemplo n.º 8
0
        private UwpControl.ParallaxView CreateParallaxView()
        {
            UwpControl.ParallaxView parallax = new UwpControl.ParallaxView();
            var binding = new Windows.UI.Xaml.Data.Binding
            {
                Source = lstView
            };

            parallax.Child         = CreateImage();
            parallax.VerticalShift = 100;
            parallax.SetBinding(UwpControl.ParallaxView.SourceProperty, binding);
            return(parallax);
        }
Ejemplo n.º 9
0
    protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
    {
        var model        = item as MyModel;
        var listViewItem = element as Windows.UI.Xaml.Controls.ListViewItem;
        var binding      = new Windows.UI.Xaml.Data.Binding
        {
            Source = model,
            Mode   = Windows.UI.Xaml.Data.BindingMode.TwoWay,
            Path   = new PropertyPath(nameof(model.IsSelected)),
        };

        listViewItem.SetBinding(Windows.UI.Xaml.Controls.ListViewItem.IsSelectedProperty, binding);
        base.PrepareContainerForItemOverride(element, item);
    }
Ejemplo n.º 10
0
        protected override void OnElementChanged(ElementChangedEventArgs <Picker> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                var b = new Windows.UI.Xaml.Data.Binding()
                {
                    Mode   = Windows.UI.Xaml.Data.BindingMode.OneWay,
                    Path   = new Windows.UI.Xaml.PropertyPath("FontSize"),
                    Source = e.NewElement
                };
                Control.SetBinding(ComboBox.FontSizeProperty, b);
            }
        }
Ejemplo n.º 11
0
        public override void OnApplyTemplate()
#endif
        {
            base.OnApplyTemplate();

            SampleSelector   = GetTemplateChild(SampleSelectorName) as Grid;
            SelectedHueColor = GetTemplateChild(SelectedHueColorName) as Rectangle;

            var body = GetTemplateChild(BodyName) as Grid;

            if (body != null)
            {
                _monitor           = new MovementMonitor();
                _monitor.Movement += _monitor_Movement;
                _monitor.MonitorControl(body);
            }

            ColorSlider = GetTemplateChild(ColorSliderName) as ColorSlider;

            if (ColorSlider != null)
            {
                if (Thumb == null)
                {
                    Thumb = new ColorSliderThumb();
                }

                ColorSlider.ColorChanged += ColorSlider_ColorChanged;

                if (SelectedHueColor != null)
                {
#if WINDOWS_STORE || WINDOWS_PHONE_APP
                    var binding = new Windows.UI.Xaml.Data.Binding();
#elif WINDOWS_PHONE
                    var binding = new System.Windows.Data.Binding();
#endif
                    binding.Source = ColorSlider;
                    binding.Path   = new PropertyPath("SolidColorBrush");

                    SelectedHueColor.SetBinding(Shape.FillProperty, binding);
                }
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Binds this wrapper object's exposed WPF DependencyProperty with the wrapped UWP object's DependencyProperty
        /// for what effectively works as a regular one- or two-way binding.
        /// </summary>
        /// <param name="propertyName">the registered name of the dependency property</param>
        /// <param name="wpfProperty">the DependencyProperty of the wrapper</param>
        /// <param name="uwpProperty">the related DependencyProperty of the UWP control</param>
        /// <param name="converter">a converter, if one's needed</param>
        /// <param name="direction">indicates that the binding should be one or two directional.  If one way, the Uwp control is only updated from the wrapper.</param>
        public void Bind(string propertyName, DependencyProperty wpfProperty, Windows.UI.Xaml.DependencyProperty uwpProperty, object converter = null, BindingDirection direction = BindingDirection.TwoWay)
        {
            if (direction == BindingDirection.TwoWay)
            {
                var binder = new Windows.UI.Xaml.Data.Binding()
                {
                    Source    = this,
                    Path      = new Windows.UI.Xaml.PropertyPath(propertyName),
                    Converter = (Windows.UI.Xaml.Data.IValueConverter)converter
                };
                Windows.UI.Xaml.Data.BindingOperations.SetBinding(ChildInternal, uwpProperty, binder);
            }

            var rebinder = new Binding()
            {
                Source    = ChildInternal,
                Path      = new PropertyPath(propertyName),
                Converter = (IValueConverter)converter
            };

            BindingOperations.SetBinding(this, wpfProperty, rebinder);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Binds this wrapper object's exposed WPF DependencyProperty with the wrapped UWP object's DependencyProperty
        /// for what effectively works as a regular one- or two-way binding.
        /// </summary>
        /// <param name="propertyName">the registered name of the dependency property</param>
        /// <param name="wpfProperty">the DependencyProperty of the wrapper</param>
        /// <param name="uwpProperty">the related DependencyProperty of the UWP control</param>
        /// <param name="converter">a converter, if one's needed</param>
        /// <param name="direction">indicates that the binding should be one or two directional.  If one way, the Uwp control is only updated from the wrapper.</param>
        public void Bind(string propertyName, System.Windows.DependencyProperty wpfProperty, WUX.DependencyProperty uwpProperty, object converter = null, System.ComponentModel.BindingDirection direction = System.ComponentModel.BindingDirection.TwoWay)
        {
            if (direction == System.ComponentModel.BindingDirection.TwoWay)
            {
                var binder = new WUX.Data.Binding()
                {
                    Source    = this,
                    Path      = new WUX.PropertyPath(propertyName),
                    Converter = (WUX.Data.IValueConverter)converter
                };
                WUX.Data.BindingOperations.SetBinding(ChildInternal, uwpProperty, binder);
            }

            var rebinder = new System.Windows.Data.Binding()
            {
                Source    = ChildInternal,
                Path      = new System.Windows.PropertyPath(propertyName),
                Converter = (System.Windows.Data.IValueConverter)converter
            };

            System.Windows.Data.BindingOperations.SetBinding(this, wpfProperty, rebinder);
        }
        public override void SubscribeToEvents()
        {
            var frameworkElement = Target as FrameworkElement;
            if (frameworkElement == null)
                return;

#if WINDOWS_PHONE || WINDOWS_WPF
            var listenerBinding = new System.Windows.Data.Binding(_targetName)
            { Source = frameworkElement };
#endif
#if NETFX_CORE
            var listenerBinding = new Windows.UI.Xaml.Data.Binding()
            {
                Path = new PropertyPath(_targetName),
                Source = frameworkElement
            };
#endif
            var attachedProperty = DependencyProperty.RegisterAttached(
                "ListenAttached" + _targetName + Guid.NewGuid().ToString("N")
                , typeof(object)
                , typeof(FrameworkElement)
                , new PropertyMetadata(null, (s, e) => FireValueChanged(e.NewValue)));
            frameworkElement.SetBinding(attachedProperty, listenerBinding);
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Prepares all bindings and content set to the Image visualized when entering edit mode.
 /// </summary>
 /// <param name="editorContent">The editor itself.</param>
 /// <param name="binding">The binding set to the editor of the cell.</param>
 public override void PrepareEditorContentVisual(FrameworkElement editorContent, Windows.UI.Xaml.Data.Binding binding)
 {
 }
Ejemplo n.º 16
0
		public override void OnApplyTemplate()
#endif
        {
            base.OnApplyTemplate();

            SampleSelector = GetTemplateChild(SampleSelectorName) as Grid;
            SelectedHueColor = GetTemplateChild(SelectedHueColorName) as Rectangle;

            var body = GetTemplateChild(BodyName) as Grid;

            if (body != null)
            {
                _monitor = new MovementMonitor();
                _monitor.Movement += _monitor_Movement;
                _monitor.MonitorControl(body);
            }

            ColorSlider = GetTemplateChild(ColorSliderName) as ColorSlider;

            if (ColorSlider != null)
            {
                if (Thumb == null)
                    Thumb = new ColorSliderThumb();

                ColorSlider.ColorChanged += ColorSlider_ColorChanged;

                if(SelectedHueColor != null)
                {
#if WINDOWS_STORE || WINDOWS_PHONE_APP
                    var binding = new Windows.UI.Xaml.Data.Binding();
#elif WINDOWS_PHONE
			        var binding = new System.Windows.Data.Binding();
#endif
                    binding.Source = ColorSlider;
                    binding.Path = new PropertyPath("SolidColorBrush");

                    SelectedHueColor.SetBinding(Shape.FillProperty, binding);
                }
            }
        }