コード例 #1
0
        /// <summary>
        /// Gets the underlying bound value.
        /// </summary>
        /// <returns>The underlying bound value.</returns>
        protected T GetUnderlyingValue()
        {
            if (!IsReadable)
            {
                throw new InvalidOperationException(PresentationStrings.BindingIsWriteOnly);
            }

            return(getter(PresentationFoundation.GetDataSourceWrapper(dependencyValue.Owner.DependencyDataSource)));
        }
コード例 #2
0
        /// <inheritdoc/>
        internal override void OnPreApplyTemplate()
        {
            if (TemplatedParent is Slider parent)
            {
                var templateWrapperType = PresentationFoundation.GetDataSourceWrapper(parent).GetType();

                if (HasDefaultValue(ValueProperty))
                {
                    BindValue(ValueProperty, templateWrapperType, "{{Value}}");
                }
                if (HasDefaultValue(MinimumProperty))
                {
                    BindValue(MinimumProperty, templateWrapperType, "{{Minimum}}");
                }
                if (HasDefaultValue(MaximumProperty))
                {
                    BindValue(MaximumProperty, templateWrapperType, "{{Maximum}}");
                }
                if (HasDefaultValue(SmallChangeProperty))
                {
                    BindValue(SmallChangeProperty, templateWrapperType, "{{SmallChange}}");
                }
                if (HasDefaultValue(LargeChangeProperty))
                {
                    BindValue(LargeChangeProperty, templateWrapperType, "{{LargeChange}}");
                }
                if (HasDefaultValue(TickPlacementProperty))
                {
                    BindValue(TickPlacementProperty, templateWrapperType, "{{TickPlacement}}");
                }
                if (HasDefaultValue(TickFrequencyProperty))
                {
                    BindValue(TickFrequencyProperty, templateWrapperType, "{{TickFrequency}}");
                }
                if (HasDefaultValue(IsDirectionReversedProperty))
                {
                    BindValue(IsDirectionReversedProperty, templateWrapperType, "{{IsDirectionReversed}}");
                }
                if (HasDefaultValue(IsSnapToTickEnabledProperty))
                {
                    BindValue(IsSnapToTickEnabledProperty, templateWrapperType, "{{IsSnapToTickEnabled}}");
                }
            }
            base.OnPreApplyTemplate();
        }
コード例 #3
0
        /// <summary>
        /// Sets the underlying bound value.
        /// </summary>
        /// <param name="value">The value to set.</param>
        protected void SetUnderlyingValue(T value)
        {
            if (!IsWritable)
            {
                throw new InvalidOperationException(PresentationStrings.BindingIsReadOnly);
            }

            var owner    = dependencyValue.Owner;
            var metadata = dependencyValue.Property.GetMetadataForOwner(owner.GetType());

            if (metadata.CoerceValueCallback != null)
            {
                value = metadata.CoerceValue <T>(owner, value);
            }

            setter(PresentationFoundation.GetDataSourceWrapper(dependencyValue.Owner.DependencyDataSource), value);
            dependencyValue.DigestImmediately();
        }
コード例 #4
0
        /// <inheritdoc/>
        internal override void OnPreApplyTemplate()
        {
            if (TemplatedParent is OrientedSlider parent)
            {
                var templateWrapperType = PresentationFoundation.GetDataSourceWrapper(parent).GetType();

                if (HasDefaultValue(MinimumProperty))
                {
                    BindValue(MinimumProperty, templateWrapperType, "{{Minimum}}");
                }
                if (HasDefaultValue(MaximumProperty))
                {
                    BindValue(MaximumProperty, templateWrapperType, "{{Maximum}}");
                }
                if (HasDefaultValue(TickFrequencyProperty))
                {
                    BindValue(TickFrequencyProperty, templateWrapperType, "{{TickFrequency}}");
                }
                if (HasDefaultValue(IsDirectionReversedProperty))
                {
                    BindValue(IsDirectionReversedProperty, templateWrapperType, "{{IsDirectionReversed}}");
                }
                if (HasDefaultValue(ReservedSpaceProperty))
                {
                    if (TemplatedParent is HSlider)
                    {
                        BindValue(ReservedSpaceProperty, templateWrapperType, "{{Track.Thumb.ActualWidth}}");
                    }
                    else
                    {
                        BindValue(ReservedSpaceProperty, templateWrapperType, "{{Track.Thumb.ActualHeight}}");
                    }
                }
            }
            base.OnPreApplyTemplate();
        }
コード例 #5
0
        /// <summary>
        /// Creates an instantiation context for the specified view.
        /// </summary>
        /// <param name="uv">The Ultraviolet context.</param>
        /// <param name="control">The control for which to create an instantiation context.</param>
        /// <returns>The instantiation context which was created.</returns>
        internal static UvmlInstantiationContext ForControl(UltravioletContext uv, Control control)
        {
            var wrapper = PresentationFoundation.GetDataSourceWrapper(control);

            return(new UvmlInstantiationContext(uv, control, control, wrapper.GetType(), control.ComponentTemplateNamescope));
        }