本文整理汇总了C#中Visual.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Visual.SetValue方法的具体用法?C# Visual.SetValue怎么用?C# Visual.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Visual
的用法示例。
在下文中一共展示了Visual.SetValue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateAdornedElement
private void UpdateAdornedElement(Visual adorner, Visual adorned)
{
var info = adorner.GetValue(AdornedElementInfoProperty);
if (info != null)
{
info.Subscription.Dispose();
if (adorned == null)
{
adorner.ClearValue(AdornedElementInfoProperty);
}
}
if (adorned != null)
{
if (info == null)
{
info = new AdornedElementInfo();
adorner.SetValue(AdornedElementInfoProperty, info);
}
info.Subscription = this.tracker.Track(adorned).Subscribe(x =>
{
info.Bounds = x;
this.InvalidateArrange();
});
}
}
示例2: SetAdornedElement
public static void SetAdornedElement(Visual adorner, Visual adorned)
{
adorner.SetValue(AdornedElementProperty, adorned);
}
示例3: SetDragsWindow
/// <summary>
/// Sets the value of the WindowMovement.DragsWindow attached property on a Visual.
/// </summary>
/// <param name="window">The Visual to set the property on.</param>
/// <param name="value">The value to set the property to.</param>
public static void SetDragsWindow(Visual visual, bool value)
{
visual.SetValue(DragsWindow, value);
}
示例4: RootChanged
protected void RootChanged(Visual oldRoot, Visual newRoot)
{
PresentationSource oldSource = null;
if (oldRoot == newRoot)
{
return;
}
// Always clear the RootSourceProperty on the old root.
if (oldRoot != null)
{
oldSource = CriticalGetPresentationSourceFromElement(oldRoot, RootSourceProperty);
oldRoot.ClearValue(RootSourceProperty);
}
// Always set the SourceProperty on the new root.
if (newRoot != null)
{
newRoot.SetValue(RootSourceProperty, new SecurityCriticalDataForMultipleGetAndSet<PresentationSource>(this));
}
UIElement oldRootUIElement = oldRoot as UIElement;
UIElement newRootUIElement = newRoot as UIElement;
// The IsVisible property can only be true if root visual is connected to a presentation source.
// For Read-Only force-inherited properties, use a private update method.
if(oldRootUIElement != null)
{
oldRootUIElement.UpdateIsVisibleCache();
}
if(newRootUIElement != null)
{
newRootUIElement.UpdateIsVisibleCache();
}
// Broadcast the Unloaded event starting at the old root visual
if (oldRootUIElement != null)
{
oldRootUIElement.OnPresentationSourceChanged(false);
}
// Broadcast the Loaded event starting at the root visual
if (newRootUIElement != null)
{
newRootUIElement.OnPresentationSourceChanged(true);
}
// To fire PresentationSourceChanged when the RootVisual changes;
// rather than simulate a "parent" pointer change, we just walk the
// collection of all nodes that need the event.
foreach (DependencyObject element in _watchers)
{
// We only need to update those elements that are in the
// same context as this presentation source.
if (element.Dispatcher == Dispatcher)
{
PresentationSource testSource = CriticalGetPresentationSourceFromElement(element,CachedSourceProperty);
// 1) If we are removing the rootvisual, then fire on any node whos old
// PresetationSource was the oldSource.
// 2) If we are attaching a rootvisual then fire on any node whos old
// PresentationSource is null;
if (oldSource == testSource || null == testSource)
{
UpdateSourceOfElement(element, null, null);
}
}
}
}
示例5: SetAdornerLayerCache
private static void SetAdornerLayerCache(Visual visual, AdornerLayer value)
{
visual.SetValue(AdornerLayerCacheProperty, value);
}
示例6: VisualTreeAvailable
/// <summary>
/// Called when style is actually applied.
/// </summary>
internal void VisualTreeAvailable(Visual v)
{
if (!ReferenceEquals(v, _oldRootVisual))
{
if (_oldRootVisual != null)
{
// Step 1: Remove the inherited NavigationService property
// This will cause a property invalidation and sub-frames will remove themselves from the parent's list
// That will cause a Journal view update so back/fwd state reflects the state of the new tree
_oldRootVisual.SetValue(NavigationServiceProperty, null);
}
if (v != null)
{
// Step 1: Set the inherited NavigationService property
// This will cause a property invalidation and sub-frames will remove themselves from the parent's list
// That will cause a Journal view update so back/fwd state reflects the state of the new tree
// Note: setting NavigationService has a non-obvious side effect -
// if v has any data-bound properties that use ElementName binding,
// the name will be resolved in the "inner scope", not the "outer
// scope". (Bug 1765041)
v.SetValue(NavigationServiceProperty, this);
}
_oldRootVisual = v;
}
}
示例7: SetDragsWindow
/// <summary>
/// Sets the value of the WindowMovement.DragsWindow attached property on a Visual.
/// </summary>
/// <param name="window">The Visual to set the property on.</param>
/// <param name="value">The value to set the property to.</param>
public static void SetDragsWindow(Visual window, bool value)
{
window.SetValue(DragsWindow, value);
}
示例8: SetSize
private void SetSize( Visual visual, double left, double top, double width, double height )
{
visual.SetValue( Canvas.LeftProperty, left );
visual.SetValue( Canvas.TopProperty, top );
visual.SetValue( Canvas.WidthProperty, width );
visual.SetValue( Canvas.HeightProperty, height );
}
示例9: SetTransformedBounds
internal static void SetTransformedBounds(Visual visual, TransformedBounds bounds)
{
visual.SetValue(TransformedBoundsProperty, bounds);
}
示例10: SetNameScope
/// <summary>
/// Sets the value of the attached <see cref="NameScopeProperty"/> on a visual.
/// </summary>
/// <param name="visual">The visual.</param>
/// <param name="value">The value to set.</param>
public static void SetNameScope(Visual visual, INameScope value)
{
visual.SetValue(NameScopeProperty, value);
}
示例11: GetImageFromVisual
private BitmapImage GetImageFromVisual(Visual visual)
{
Thickness margin = (Thickness)visual.GetValue(MarginProperty);
if (margin == null | margin.Equals(new Thickness(0)))
{
visual.SetValue(MarginProperty, new Thickness(0));
}
MemoryStream memory = new MemoryStream();
RenderTargetBitmap bitmap = new RenderTargetBitmap(
Convert.ToInt32(visual.GetValue(ActualWidthProperty)),
Convert.ToInt32(visual.GetValue(ActualHeightProperty)),
96,
96,
PixelFormats.Pbgra32);
bitmap.Render(visual);
PngBitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bitmap));
encoder.Save(memory);
BitmapImage img = new BitmapImage();
img.BeginInit();
img.StreamSource = new MemoryStream(memory.ToArray());
img.EndInit();
memory.Dispose();
visual.SetValue(MarginProperty, margin);
return img;
}