本文整理汇总了C#中System.Windows.DependencyObject.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# DependencyObject.SetValue方法的具体用法?C# DependencyObject.SetValue怎么用?C# DependencyObject.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.DependencyObject
的用法示例。
在下文中一共展示了DependencyObject.SetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTransformChanged
private static void OnTransformChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
d.SetValue(UIElement.RenderTransformProperty, e.NewValue);
if (TrackableRenderTransform.TransformChanged == null)
return;
TrackableRenderTransform.TransformChanged(d, e);
}
示例2: SetElementPolicy
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;
}
}
示例3: SetTextLength
public static void SetTextLength(DependencyObject obj, int value)
{
obj.SetValue(TextLengthProperty, value);
if (value >= 1)
obj.SetValue(HasTextProperty, true);
else obj.SetValue(HasTextProperty, false);
}
示例4: SetTextLength
private static void SetTextLength(
DependencyObject obj,
int value)
{
obj.SetValue(TextLengthProperty, value);
obj.SetValue(HasTextProperty, value >= 1);
}
示例5: SetPropertyValueOnTarget
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;
}
示例6: OnIconPropertyChanged
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));
}
示例7: OnPropertyChanged
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);
}
示例8: OnUseLayoutRoundingChanged
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: SetAttachedProperties
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: ExpressionPropertyChangedCallback
public static void ExpressionPropertyChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
try
{
d.SetValue(RegExpressionProperty, new Regex(e.NewValue.ToString()));
}
catch
{
d.SetValue(RegExpressionProperty, null);
}
}
示例11: SetSelectedItemsSource
public static void SetSelectedItemsSource(DependencyObject element, IList value)
{
if (element == null)
throw new ArgumentNullException("element");
element.SetValue(SelectedItemsSourceProperty, value);
}
示例12: SetSortField
public static void SetSortField(DependencyObject obj, string value)
{
if (obj == null)
throw new ArgumentNullException("obj");
obj.SetValue(SortFieldProperty, value);
}
示例13: SetHeaderSort
public static void SetHeaderSort(DependencyObject obj, bool value)
{
if (obj == null)
throw new ArgumentNullException("obj");
obj.SetValue(HeaderSortProperty, value);
}
示例14: OnDriveChanged
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);
}
示例15: SetWidthPix
/// <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);
}
}