本文整理汇总了C#中System.Windows.FrameworkElement.ClearValue方法的典型用法代码示例。如果您正苦于以下问题:C# FrameworkElement.ClearValue方法的具体用法?C# FrameworkElement.ClearValue怎么用?C# FrameworkElement.ClearValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.FrameworkElement
的用法示例。
在下文中一共展示了FrameworkElement.ClearValue方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ClearLocalValues
public static void ClearLocalValues(FrameworkElement itemsPresenter, Popup popup)
{
if (itemsPresenter != null)
{
itemsPresenter.ClearValue(FrameworkElement.HeightProperty);
itemsPresenter.ClearValue(FrameworkElement.WidthProperty);
}
if (popup != null)
{
popup.ClearValue(Popup.PlacementProperty);
popup.ClearValue(Popup.VerticalOffsetProperty);
popup.ClearValue(Popup.HorizontalOffsetProperty);
}
}
示例2: UpdateProperty
internal void UpdateProperty( FrameworkElement element, DependencyProperty elementProp, DependencyProperty definitionProperty )
{
object currentValue = this.GetValue( definitionProperty );
object localValue = this.ReadLocalValue( definitionProperty );
object elementValue = element.GetValue( elementProp );
bool areEquals = false;
// Avoid setting values if it does not affect anything
// because setting a local value may prevent a style setter from being active.
if( localValue != DependencyProperty.UnsetValue )
{
if( ( elementValue != null ) && ( currentValue != null ) )
{
areEquals = ( elementValue.GetType().IsValueType && currentValue.GetType().IsValueType )
? elementValue.Equals( currentValue ) // Value Types
: currentValue == element.GetValue( elementProp ); // Reference Types
}
if( !areEquals )
{
element.SetValue( elementProp, currentValue );
}
else
{
element.ClearValue( elementProp );
}
}
}
示例3: CaptureSnapshot
/// <summary>Captures a snapshot of the source element as a bitmap image. The snapshot is created based on the specified rendering parameters.</summary>
/// <param name="sourceElement">The source element.</param>
/// <param name="bitmapSize">The bitmap size.</param>
/// <param name="scalingMode">The bitmap scaling mode.</param>
/// <param name="bitmapDpi">The bitmap dpi.</param>
/// <param name="pixelFormat">The bitmap pixel format.</param>
/// <returns>The snapshot of the source element.</returns>
public static BitmapSource CaptureSnapshot(FrameworkElement sourceElement, Size bitmapSize, BitmapScalingMode scalingMode, Vector bitmapDpi, PixelFormat pixelFormat) {
if (sourceElement == null || bitmapSize.IsZero()) return null;
var snapshot = new RenderTargetBitmap((int)bitmapSize.Width, (int)bitmapSize.Height, bitmapDpi.X, bitmapDpi.Y, pixelFormat);
sourceElement.SetValue(RenderOptions.BitmapScalingModeProperty, scalingMode);
snapshot.Render(sourceElement);
sourceElement.ClearValue(RenderOptions.BitmapScalingModeProperty);
snapshot.Freeze();
return snapshot;
}
示例4: UpdateProperty
internal void UpdateProperty( FrameworkElement element, DependencyProperty elementProp, DependencyProperty definitionProperty )
{
object currentValue = this.GetValue( definitionProperty );
object localValue = this.ReadLocalValue( definitionProperty );
// Avoid setting values if it does not affect anything
// because setting a local value may prevent a style setter from being active.
if( ( localValue != DependencyProperty.UnsetValue )
|| currentValue != element.GetValue( elementProp ) )
{
element.SetValue( elementProp, currentValue );
}
else
{
element.ClearValue( elementProp );
}
}
示例5: ValidationIcon_Changed
private static void ValidationIcon_Changed (FrameworkElement control, DpChangedEventArgs<FrameworkElement> args)
{
if (args.OldValue != null) {
control.SizeChanged -= UpdatePopup;
control.GotKeyboardFocus -= UpdatePopup;
control.LostKeyboardFocus -= UpdatePopup;
if (control is TextBoxBase)
((TextBox)control).TextChanged -= UpdatePopup;
control.ClearValue(Validation.ErrorTemplateProperty);
}
if (args.NewValue != null) {
GetOrCreateTooltipPopup(control);
control.SizeChanged += UpdatePopup;
control.GotKeyboardFocus += UpdatePopup;
control.LostKeyboardFocus += UpdatePopup;
if (control is TextBoxBase)
((TextBox)control).TextChanged += UpdatePopup;
control.SetValue(Validation.ErrorTemplateProperty, null);
}
UpdatePopup(control, EventArgs.Empty);
}
示例6: DetachBehavior
private static void DetachBehavior(FrameworkElement element)
{
var behavior = GetBehavior(element);
behavior.Detach(element);
element.ClearValue(BehaviorProperty);
}
示例7: UnWireCommand
private static void UnWireCommand(FrameworkElement element, ICommand oldValue)
{
var state = GetCommandState(element);
if (oldValue == null)
{
Debug.Assert(state == null);
}
else
{
Debug.Assert(state != null);
state._owner.MouseLeftButtonDown -= source_MouseLeftButtonDown;
oldValue.CanExecuteChanged -= state.Command_CanExecuteChanged;
element.ClearValue(CommandStateProperty);
}
}
示例8: ClearModel
private void ClearModel (FrameworkElement elt, object item)
{
ModelUIElement3D model = elt.GetValue(LinkedModelProperty) as ModelUIElement3D;
_modelContainer.Children.Remove(model);
// Update the positions of all model items
int removed = (int) model.GetValue(LinkedElementPositionProperty);
foreach (Visual3D m in _modelContainer.Children) {
int val = (int) m.GetValue(LinkedElementPositionProperty);
if (val > removed) {
m.SetValue(LinkedElementPositionProperty, val - 1);
}
}
model.ClearValue(LinkedElementProperty);
elt.ClearValue(LinkedModelProperty);
// Update SelectedIndex if needed
if (SelectedIndex >= 0 && SelectedIndex < Items.Count)
{
ReflowItems();
}
else
{
SelectedIndex = Math.Max(0, Math.Min(SelectedIndex, Items.Count - 1));
}
}
示例9: SetFixedTranslateTransformCore
private static bool SetFixedTranslateTransformCore( FrameworkElement element, bool canScrollHorizontally )
{
Debug.Assert( element != null );
var parentScrollViewer = TableViewScrollViewer.GetParentScrollViewer( element ) as ScrollViewer;
if( parentScrollViewer == null )
return false;
var fixedTransform = TableViewScrollViewer.GetStoredFixedTransform( parentScrollViewer );
Debug.Assert( fixedTransform != null );
if( canScrollHorizontally )
{
if( element.RenderTransform == fixedTransform )
{
element.ClearValue( UIElement.RenderTransformProperty );
}
}
else
{
element.RenderTransform = fixedTransform;
}
return true;
}
示例10: ClearModel
private void ClearModel(FrameworkElement elt, object item)
{
ModelUIElement3D model = elt.GetValue(LinkedModelProperty) as ModelUIElement3D;
_modelContainer.Children.Remove(model);
model.ClearValue(LinkedElementProperty);
elt.ClearValue(LinkedModelProperty);
// Update SelectedIndex if needed
if (SelectedIndex >= 0 && SelectedIndex < Items.Count)
{
ReflowItems();
}
else
{
SelectedIndex = Math.Max(0, Math.Min(SelectedIndex, Items.Count - 1));
}
}
示例11: BindActiveMarker
private static void BindActiveMarker(FrameworkElement d)
{
IMarkerSelector selector = GetSelector(d);
if (selector == null)
{
d.ClearValue(ActiveMarkerProperty);
}
else
{
d.SetBinding(ActiveMarkerProperty, new System.Windows.Data.Binding("ActiveMarker") { Source = selector });
}
}
示例12: ClearContainerForItem
public void ClearContainerForItem(object item, FrameworkElement container)
{
container.ClearValue(ItemForItemContainerProperty);
Containers.Remove(item);
}