SetValue() публичный метод

public SetValue ( DependencyProperty dp, object value ) : void
dp DependencyProperty
value object
Результат void
Пример #1
1
 private static void OnTransformChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     d.SetValue(UIElement.RenderTransformProperty, e.NewValue);
     if (TrackableRenderTransform.TransformChanged == null)
         return;
     TrackableRenderTransform.TransformChanged(d, e);
 }
Пример #2
0
        private static void SetElementPolicy(DependencyObject element, string code, OperationAction action)
        {
            if (SystemInfo.OperationCodes == null || SystemInfo.OperationCodes.Count == 0)
                return;

            var containCode = SystemInfo.OperationCodes.Contains(code);
            if (containCode)
                return;

            switch (action)
            {
                case OperationAction.Disable:
                    {
                        element.SetValue(Control.IsEnabledProperty, false);
                        element.SetValue(Control.VisibilityProperty, Visibility.Visible);
                        break;
                    }
                case OperationAction.Hide:
                    {
                        element.SetValue(Control.VisibilityProperty, Visibility.Collapsed);
                        element.SetValue(Control.IsEnabledProperty, true);
                        break;
                    }
                default:
                    break;
            }

        }
        public static bool SetPropertyValueOnTarget(DependencyObject target, string propertyName,bool ballowed)
        {
            var prop = GetDependencyProperty(target, propertyName);

            if (target.GetValue(prop) == null || target.GetValue(prop).GetType() == typeof(string))
            {
                if (!ballowed)
                {
                    target.SetValue(prop, String.Empty);
                }
                return true;
            }

            if (target.GetValue(prop).GetType() == typeof(bool))
            {
                target.SetValue(prop, ballowed);
                return true;
            }

            if (target.GetValue(prop).GetType() == typeof(Visibility))
            {
                if (ballowed)
                {
                    target.SetValue(prop, Visibility.Visible);
                }
                else
                {
                    target.SetValue(prop, Visibility.Collapsed);
                }
                return true;
            }

            return false;
        }
 public static void SetTextLength(DependencyObject obj, int value)
 {
     obj.SetValue(TextLengthProperty, value);
     if (value >= 1)
         obj.SetValue(HasTextProperty, true);
     else obj.SetValue(HasTextProperty, false);
 }
Пример #5
0
 private static void SetTextLength(
                                   DependencyObject obj,
                                   int value)
 {
     obj.SetValue(TextLengthProperty, value);
     obj.SetValue(HasTextProperty, value >= 1);
 }
Пример #6
0
		private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
		{
			var sourceValue = d.GetValue(ExtendedBinding.SourceProperty);
			var targetValue = d.GetValue(ExtendedBinding.TargetProperty);
			if (e.Property == ExtendedBinding.SourceProperty && !object.ReferenceEquals(sourceValue, targetValue))
				d.SetValue(ExtendedBinding.TargetProperty, sourceValue);
			else if (e.Property == ExtendedBinding.TargetProperty && !object.ReferenceEquals(sourceValue, targetValue))
				d.SetValue(ExtendedBinding.SourceProperty, targetValue);
		}
        private static void OnIconPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
#if NET40
            d.SetValue(TextOptions.TextRenderingModeProperty, TextRenderingMode.ClearType);
#endif
            d.SetValue(FontFamilyProperty, FontAwesomeFontFamily);
            d.SetValue(TextAlignmentProperty, TextAlignment.Center);
            d.SetValue(TextProperty, char.ConvertFromUtf32((int)e.NewValue));
        }
Пример #8
0
 private static void OnUseLayoutRoundingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     d.SetValue(UIElement.SnapsToDevicePixelsProperty, true);
     #if NET35
     #else
     RenderOptions.SetClearTypeHint(d, ClearTypeHint.Enabled);
     d.SetValue(FrameworkElement.UseLayoutRoundingProperty, true);
     #endif
 }
Пример #9
0
        private void SetAttachedProperties(DependencyObject element)
        {
            if (Positioned) return;

            element.SetValue(Grid.RowProperty, Row);
            element.SetValue(Grid.ColumnProperty, Column);
            element.SetValue(Grid.RowSpanProperty, RowSpan);
            element.SetValue(Grid.ColumnSpanProperty, ColumnSpan);

            Positioned = true;
        }
Пример #10
0
 public static void ExpressionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     try
     {
         d.SetValue(RegExpressionProperty, new Regex(e.NewValue.ToString()));
     }
     catch
     {
         d.SetValue(RegExpressionProperty, null);
     }
     
 }
Пример #11
0
 public static ElementDrawCollection GetElementDraws(DependencyObject obj)
 {
     if (Caliburn.PresentationFramework.PresentationFrameworkModule.IsInDesignMode) return new ElementDrawCollection();
     var draws = (ElementDrawCollection)obj.GetValue(ElementDrawsProperty) ?? new ElementDrawCollection(obj as FrameworkElement);
     obj.SetValue(ElementDrawsProperty, draws);
     return draws;
 }
Пример #12
0
 private static void OnAttachChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     Action<System.Windows.Interactivity.TriggerBase> action = null;
     System.Windows.Interactivity.TriggerCollection allTriggers;
     if (e.NewValue != e.OldValue)
     {
         System.Windows.Interactivity.TriggerBase[] enumerable = (System.Windows.Interactivity.TriggerBase[]) d.GetValue(MessageTriggersProperty);
         allTriggers = Interaction.GetTriggers(d);
         if (enumerable != null)
         {
             if (action == null)
             {
                 action = (Action<System.Windows.Interactivity.TriggerBase>) (x => allTriggers.Remove(x));
             }
             enumerable.Apply<System.Windows.Interactivity.TriggerBase>(action);
         }
         System.Windows.Interactivity.TriggerBase[] baseArray2 = Parser.Parse(d, e.NewValue as string).ToArray<System.Windows.Interactivity.TriggerBase>();
         baseArray2.Apply<System.Windows.Interactivity.TriggerBase>(new Action<System.Windows.Interactivity.TriggerBase>(allTriggers.Add));
         if (baseArray2.Length > 0)
         {
             d.SetValue(MessageTriggersProperty, baseArray2);
         }
         else
         {
             d.ClearValue(MessageTriggersProperty);
         }
     }
 }
Пример #13
0
        /// <summary>
        /// Sets the update source on change.
        /// </summary>
        /// <param name="obj">The object.</param>
        /// <param name="value">if set to <c>true</c> [value].</param>
        /// <exception cref="System.ArgumentNullException">obj</exception>
        public static void SetUpdateSourceOnChange
          (DependencyObject obj, bool value)
        {
            if (obj == null) throw new ArgumentNullException("obj");

            obj.SetValue(UpdateSourceOnChangeProperty, value);
        }
Пример #14
0
        /// <summary>
        /// Sets the value of the <see cref="ErrorMessageProperty"/> property.
        /// </summary>
        /// <param name="dependencyObject">
        /// The dependency object.
        /// </param>
        /// <param name="value">
        /// The property value.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="dependencyObject"/> parameter is null.
        /// </exception>
        public static void SetErrorMessage(DependencyObject dependencyObject, string value)
        {
            if (dependencyObject == null)
                throw new ArgumentNullException("dependencyObject");

            dependencyObject.SetValue(ErrorMessageProperty, value);
        }
Пример #15
0
        static void ModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (Bootstrapper.IsInDesignMode || e.NewValue == null || e.NewValue == e.OldValue)
                return;

            var fe = d as FrameworkElement;
            if (fe == null)
                return;

            View.ExecuteOnLoad(fe, delegate {
                var target = e.NewValue;
                var containerKey = e.NewValue as string;

                if(containerKey != null)
                    target = IoC.GetInstance(null, containerKey);

                d.SetValue(View.IsScopeRootProperty, true);

                string context = string.IsNullOrEmpty(fe.Name)
                    ? fe.GetHashCode().ToString()
                    : fe.Name;

                ViewModelBinder.Bind(target, d, context);
            });
        }
Пример #16
0
		public static void OnDriveChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
		{
			FreeSpaceInfo o = (FreeSpaceInfo)d;
			// check if the drive property is empty
			if (((string)e.NewValue).Length > 0)
			{
				// get data about the drive
				o.currentDriveInfo = new DriveInfo((string)e.NewValue);
				// set dependency property
				d.SetValue(FreeSpaceRatioProperty, 
					Convert.ToDouble(o.currentDriveInfo.TotalFreeSpace) / o.currentDriveInfo.TotalSize);
			}
			else
				// no drive has been selected -> set free space ratio to zero
				d.SetValue(FreeSpaceRatioProperty, 0.0);
		}
Пример #17
0
 /// <summary>
 /// Set focus property.
 /// </summary>
 /// <param name="obj">Control that should we checked be focused.</param>
 /// <param name="value">Value of focused property.</param>
 public static void SetIsFocused(DependencyObject obj, bool value)
 {
     if (obj != null)
     {
         obj.SetValue(IsFocusedProperty, value);
     }
 }
Пример #18
0
        public void Any_DependencyObject_is_ScopeRoot_if_IsScopeRoot_is_true() {
            var dependencyObject = new DependencyObject();
            dependencyObject.SetValue(View.IsScopeRootProperty, true);
            var route = BindingScope.FindScopeNamingRoute(dependencyObject);

            Assert.Same(dependencyObject, route.Root);
        }
Пример #19
0
		public static void UpdateForceClearTypeIfNeeded(DependencyObject target, bool forceClearTypeIfNeeded, IClassificationFormatMap classificationFormatMap) {
			if (target == null)
				throw new ArgumentNullException(nameof(target));
			if (classificationFormatMap == null)
				throw new ArgumentNullException(nameof(classificationFormatMap));

			// Remote Desktop seems to force disable-ClearType so to prevent Consolas from looking
			// really ugly and to prevent the colors (eg. keyword color) to look like different
			// colors, force ClearType if the font is Consolas. VS also does this.
			var fontName = classificationFormatMap.DefaultTextProperties.GetFontName();
			bool forceClearType = forceClearTypeIfNeeded && IsForceClearTypeFontName(fontName);
			if (forceClearType)
				target.SetValue(TextOptions.TextRenderingModeProperty, TextRenderingMode.ClearType);
			else
				target.SetValue(TextOptions.TextRenderingModeProperty, TextRenderingMode.Auto);
		}
Пример #20
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="value"></param>
 public static void SetWidthPix(DependencyObject obj, int value)
 {
     if (value > 0)
     {
         obj.SetValue(WidthPixProperty, value);
     }
 }
Пример #21
0
		public static void SetVirtualizationMode (DependencyObject element, VirtualizationMode mode)
		{
			if (element == null)
				throw new ArgumentNullException ("element");
			
			element.SetValue (VirtualizingStackPanel.VirtualizationModeProperty, mode);
		}
Пример #22
0
        /// <summary>
        /// Sets the value of the <see cref="P:DigitalRune.Window.AccessKeyScope.IsEnabled"/>
        /// attached property to a given <see cref="DependencyObject"/> object.
        /// </summary>
        /// <param name="obj">The object on which to set the property value.</param>
        /// <param name="value">The property value to set.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="obj"/> is <see langword="null"/>.
        /// </exception>
        public static void SetIsEnabled(DependencyObject obj, bool value)
        {
            if (obj == null)
                throw new ArgumentNullException(nameof(obj));

            obj.SetValue(IsEnabledProperty, Boxed.Get(value));
        }
Пример #23
0
 private static void OnDesignBackgroundChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     if (DesignerProperties.GetIsInDesignMode(d))
     {
         d.SetValue(Control.BackgroundProperty, e.NewValue);
     }
 }
Пример #24
0
        /// <summary>
        /// Sets the <see cref="RegionNameProperty"/> attached property.
        /// </summary>
        /// <param name="regionTarget">The object to adapt. This is typically a container (i.e a control).</param>
        /// <param name="regionName">The name of the region to register.</param>
        public static void SetRegionName(DependencyObject regionTarget, string regionName)
        {
            if (regionTarget == null)
                throw new ArgumentNullException(nameof(regionTarget));

            regionTarget.SetValue(RegionNameProperty, regionName);
        }
        public static void SetHeaderSort(DependencyObject obj, bool value)
        {
            if (obj == null)
                throw new ArgumentNullException("obj");

            obj.SetValue(HeaderSortProperty, value);
        }
        public static void SetGenerateColumns(DependencyObject element, bool value) {
            if (element == null) {
                throw new ArgumentNullException("element");
            }

            element.SetValue(GenerateColumnsProperty, value);
        }
        public static void SetSortField(DependencyObject obj, string value)
        {
            if (obj == null)
                throw new ArgumentNullException("obj");

            obj.SetValue(SortFieldProperty, value);
        }
Пример #28
0
 public static void SetScrollEffect(DependencyObject obj, int value)
 {
     var elem = obj as FrameworkElement;
     var transGroup = new TransformGroup();
     transGroup.Children.Add(new ScaleTransform());
     transGroup.Children.Add(new SkewTransform());
     transGroup.Children.Add(new RotateTransform());
     transGroup.Children.Add(new TranslateTransform());
     elem.RenderTransform = transGroup;
     var sb = new Storyboard();
     var da = new DoubleAnimationUsingKeyFrames();
     Storyboard.SetTarget(da, obj);
     Storyboard.SetTargetProperty(da, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)", new object[0]));
     da.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.Zero), Value = 60 });
     da.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(value)), Value = 60 });
     da.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(value + 900)), Value = 0, EasingFunction = new CircleEase { EasingMode = EasingMode.EaseOut } });
     sb.Children.Add(da);
     var da2 = new DoubleAnimationUsingKeyFrames();
     Storyboard.SetTarget(da2, obj);
     Storyboard.SetTargetProperty(da2, new PropertyPath(UIElement.OpacityProperty));
     da2.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.Zero), Value = 0 });
     da2.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(value)), Value = 0 });
     da2.KeyFrames.Add(new EasingDoubleKeyFrame { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(value + 400)), Value = 1 });
     sb.Children.Add(da2);
     elem.Loaded += (a, b) =>
     {
         sb.Begin();
     };
     obj.SetValue(ScrollEffectProperty, value);
 }
Пример #29
0
        public static void SetLoadBindingsFromVM(DependencyObject obj, bool value)
        {
            if (obj == null)
                throw new ArgumentNullException("obj");

            obj.SetValue(LoadBindingsFromVMProperty, value);
        }
Пример #30
0
        public static void SetSelectedItemsSource(DependencyObject element, IList value)
        {
            if (element == null)
                throw new ArgumentNullException("element");

            element.SetValue(SelectedItemsSourceProperty, value);
        }
Пример #31
0
 public static void SetValueThreadSafe(this System.Windows.DependencyObject obj, System.Windows.DependencyProperty p, object value)
 {
     obj.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background,
                                (System.Threading.SendOrPostCallback) delegate
     {
         obj.SetValue(p, value);
     }, value);
 }
Пример #32
0
 public static void SetId(Windows.DependencyObject target, string id) => target.SetValue(IdProperty, id);
 public static void SetCanvasPos(this System.Windows.DependencyObject obj, Point point)
 {
     obj.SetValue(Canvas.LeftProperty, (object)point.X);
     obj.SetValue(Canvas.TopProperty, (object)point.Y);
 }
Пример #34
0
 public static void SetControlEditInitialized(sw.DependencyObject obj, bool value) => obj.SetValue(CellProperties.ControlEditInitializedProperty, value);
 public static void SetSelectedItem(System.Windows.DependencyObject obj, object value)
 {
     obj.SetValue(SelectedItemProperty, value);
 }
Пример #36
0
 public static void SetReportSource(System.Windows.DependencyObject target, object value)
 {
     target.SetValue(ReportSourceProperty, value);
 }