本文整理汇总了C#中System.Windows.DependencyObject.CoerceValue方法的典型用法代码示例。如果您正苦于以下问题:C# DependencyObject.CoerceValue方法的具体用法?C# DependencyObject.CoerceValue怎么用?C# DependencyObject.CoerceValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.DependencyObject
的用法示例。
在下文中一共展示了DependencyObject.CoerceValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTimeSpanPropertyChanged
static void OnTimeSpanPropertyChanged(DependencyObject dp, DependencyPropertyChangedEventArgs e)
{
TimePicker timePicker = dp as TimePicker;
if (e.Property == TimeSpanProperty)
{
if (timePicker != null)
{
if (timePicker.TimeSpan.Days > 0)
{
if (timePicker.IsFullDay)
timePicker.TextBox.Text = "24:00";
else timePicker.TextBox.Text = "23:59";
}
else timePicker.TextBox.Text = timePicker.TimeSpan.Hours.ToString("D2") + ":" + timePicker.TimeSpan.Minutes.ToString("D2");
}
dp.CoerceValue(TimeSpanProperty);
}
}
示例2: UpdateDefaultControlSizeDefinition
private static void UpdateDefaultControlSizeDefinition(DependencyObject d)
{
d.CoerceValue(DefaultControlSizeDefinitionProperty);
// If the element belongs to a ControlGroup, then
// coerce DefaultControlSizeDefinition for the ControlGroup too.
if (RibbonControlService.GetIsInControlGroup(d))
{
RibbonControlGroup controlGroup = TreeHelper.FindVisualAncestor<RibbonControlGroup>(d);
if (controlGroup != null)
{
controlGroup.CoerceValue(DefaultControlSizeDefinitionProperty);
}
}
}
示例3: OnValueChanged
/// <summary>
/// Handles changes to the Value property.
/// </summary>
private static void OnValueChanged(DependencyObject d,
DependencyPropertyChangedEventArgs e)
{
d.CoerceValue(MinimumProperty);
d.CoerceValue(MaximumProperty);
StarControl starControl = (StarControl)d;
if (starControl.Value == 0.0m)
{
starControl.starForeground.Fill = Brushes.Gray;
}
else
{
starControl.starForeground.Fill = starControl.StarForegroundColor;
}
Int32 marginLeftOffset = (Int32)(starControl.Value * (Decimal)STAR_SIZE);
starControl.mask.Margin = new Thickness(marginLeftOffset, 0, 0, 0);
starControl.InvalidateArrange();
starControl.InvalidateMeasure();
starControl.InvalidateVisual();
}
示例4: OnMinimumChanged
private static void OnMinimumChanged(DependencyObject element, DependencyPropertyChangedEventArgs args)
{
element.CoerceValue(MaximumProperty);
element.CoerceValue(ValueProperty);
}
示例5: TransferProperty
/// <summary>
/// Causes the given DependencyProperty to be coerced in transfer mode.
/// </summary>
/// <remarks>
/// This should be called from within the target object's NotifyPropertyChanged. It MUST be called in
/// response to a change in the target property.
/// </remarks>
/// <param name="d">The DependencyObject which contains the property that needs to be transfered.</param>
/// <param name="p">The DependencyProperty that is the target of the property transfer.</param>
public static void TransferProperty(DependencyObject d, DependencyProperty p)
{
var transferEnabledMap = GetPropertyTransferEnabledMapForObject(d);
transferEnabledMap[p] = true;
d.CoerceValue(p);
transferEnabledMap[p] = false;
}
示例6: RestoreValue
private static void RestoreValue(DependencyObject d, DependencyProperty property, ValueAndValueSource v)
{
Debug.Assert(d != null);
Debug.Assert(property != null);
Debug.Assert(v != null);
if (v.ValueSource == BaseValueSource.Local)
{
d.SetValue(property, v.Value);
}
else
{
d.ClearValue(property);
d.CoerceValue(property);
}
}
示例7: OnCommandChanged
// Performs proper hooking/unhooking and coerces QAT ID.
//
// All Ribbon controls should hook this delegate to coerce the QAT ID whenever the Command changes.
internal static void OnCommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
d.CoerceValue(RibbonControlService.QuickAccessToolBarIdProperty);
}
示例8: OnRowStyleSelectorChanged
private static void OnRowStyleSelectorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
d.CoerceValue(ItemContainerStyleSelectorProperty);
}
示例9: OnPositionChanged
private static void OnPositionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
d.CoerceValue(PositionProperty);
(d as MediaSeekSlider).Value = (d as MediaSeekSlider).Position;
}
示例10: OnCategoryTemplateChanged
private static void OnCategoryTemplateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
d.CoerceValue(ItemTemplateProperty);
}
示例11: OnCategoryStyleChanged
private static void OnCategoryStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
d.CoerceValue(ItemContainerStyleProperty);
}
示例12: StupidDIckheadPropertyHCanged
private static void StupidDIckheadPropertyHCanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
{
ErrorProvider p = e.NewValue as ErrorProvider;
p.Errors.CollectionChanged +=
delegate(object sender, NotifyCollectionChangedEventArgs nce) {
o.CoerceValue(HasErrorMessageProperty);
o.CoerceValue(ErrorMessageProperty);
};
}
示例13: IsToolWindowChanged
private static void IsToolWindowChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
d.CoerceValue(CanRaftProperty);
d.CoerceValue(CanBecomeDocumentProperty);
d.CoerceValue(DefaultDockProperty);
}
示例14: OnDefaultControlSizeDefinitionChanged
private static void OnDefaultControlSizeDefinitionChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
d.CoerceValue(ControlSizeDefinitionProperty);
}
示例15: CoerceControlSizeDefinition
private static object CoerceControlSizeDefinition(DependencyObject d, object baseValue)
{
if (baseValue == null)
{
RibbonControlSizeDefinition defaultControlSizeDefinition = RibbonControlService.GetDefaultControlSizeDefinition(d);
if (defaultControlSizeDefinition == null)
{
d.CoerceValue(DefaultControlSizeDefinitionProperty);
defaultControlSizeDefinition = RibbonControlService.GetDefaultControlSizeDefinition(d);
}
return defaultControlSizeDefinition;
}
return baseValue;
}