本文整理汇总了C#中UIElement.ReadLocalValue方法的典型用法代码示例。如果您正苦于以下问题:C# UIElement.ReadLocalValue方法的具体用法?C# UIElement.ReadLocalValue怎么用?C# UIElement.ReadLocalValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIElement
的用法示例。
在下文中一共展示了UIElement.ReadLocalValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CellRange
/// <summary>
/// Initializes a new instance of a <see cref="T:C1.WPF.FlexGrid.CellRange" /> based on a
/// <see cref="T:System.Windows.UIElement" /> that represents a cell.
/// </summary>
/// <param name="e">
/// <see cref="T:System.Windows.UIElement" /> that represents a cell.
/// </param>
public CellRange(UIElement e)
{
if (e.ReadLocalValue(Grid.RowProperty) == DependencyProperty.UnsetValue)
{
_row = _col = _row2 = _col2 = -1;
return;
}
_row = (int) e.GetValue(Grid.RowProperty);
_col = (int) e.GetValue(Grid.ColumnProperty);
_row2 = _row + (int) e.GetValue(Grid.RowSpanProperty) - 1;
_col2 = _col + (int) e.GetValue(Grid.ColumnSpanProperty) - 1;
}
示例2: TransferProperty
private static void TransferProperty(UIElement original, UIElement clone, DependencyProperty originalProperty, DependencyProperty cloneProperty, TransferMode mode)
{
bool performTransfer = false;
if ((mode & TransferMode.AlwaysTransfer) == TransferMode.AlwaysTransfer)
{
performTransfer |= DependencyPropertyHelper.GetValueSource(original, originalProperty).BaseValueSource > BaseValueSource.Default;
}
else if ((mode & TransferMode.OnlyTransferIfTemplateBound) == TransferMode.OnlyTransferIfTemplateBound)
{
performTransfer |= DependencyPropertyHelper.GetValueSource(original, originalProperty).BaseValueSource >= BaseValueSource.ParentTemplate;
}
if (performTransfer)
{
// Actually perform the transfer.
BindingBase binding = BindingOperations.GetBindingBase(original, originalProperty);
if (binding != null)
{
// Transfer Bindings
BindingOperations.SetBinding(clone, cloneProperty, binding);
}
else
{
Expression expr = original.ReadLocalValue(originalProperty) as Expression;
if (expr != null)
{
// Transfer DynamicResource
DynamicResourceExtension dynamicResource = _rreConverter.ConvertTo(expr, typeof(MarkupExtension)) as DynamicResourceExtension;
if (dynamicResource != null)
{
clone.SetValue(cloneProperty, dynamicResource.ProvideValue(null));
}
}
else
{
// Transfer other DPs
object originalValue = original.GetValue(originalProperty);
clone.SetValue(cloneProperty, CreateClone(originalValue));
}
}
}
}
示例3: IsPropertySet
static bool IsPropertySet(UIElement element, DependencyProperty d)
{
return element.ReadLocalValue(d) != DependencyProperty.UnsetValue;
}
示例4: EnableElementNavigation
private void EnableElementNavigation( UIElement child )
{
//checking only one of the 2 properties... This is because they are set together.
if( child.ReadLocalValue( TableflowViewItemsHost.PreviousDirectionalNavigationModeProperty ) != DependencyProperty.UnsetValue )
{
KeyboardNavigation.SetDirectionalNavigation( child, TableflowViewItemsHost.GetPreviousDirectionalNavigationMode( child ) );
KeyboardNavigation.SetTabNavigation( child, TableflowViewItemsHost.GetPreviousTabNavigationMode( child ) );
}
//If unset, then nothing to do in this method!
}
示例5: ShowAdorner
private static void ShowAdorner(UIElement targetElement, bool show, bool retry = true)
{
if (targetElement == null)
{
return;
}
var adornerLayer = AdornerLayer.GetAdornerLayer(targetElement);
if (adornerLayer == null)
{
if (retry)
{
targetElement.Dispatcher.BeginInvoke(
DispatcherPriority.Loaded,
new Action(() => ShowAdorner(targetElement, show, false)));
}
return;
}
var adorner = targetElement.ReadLocalValue(AdornerProperty) as TemplatedAdorner;
if (show && adorner == null)
{
var validationTemplate = GetTemplate(targetElement);
if (validationTemplate != null)
{
adorner = new TemplatedAdorner(targetElement, validationTemplate);
adornerLayer.Add(adorner);
targetElement.SetValue(AdornerProperty, adorner);
}
}
else if (!show && adorner != null)
{
adorner.ClearChild();
adornerLayer.Remove(adorner);
targetElement.ClearValue(AdornerProperty);
}
}
示例6: GetItemPosition
private Rect GetItemPosition(Size arrangeSize, UIElement item)
{
if (item is ContentPresenter && item.ReadLocalValue(PositionProperty) == DependencyProperty.UnsetValue)
{ //should this be recursive until uielement with set Position is found?
var elm = VisualTreeHelper.GetChild(item, 0) as UIElement;
if (elm != null)
item = elm;
}
var pos = GetPosition(item);
var range = GetRange(item);
var align = GetAlignment(item);
double x = 0;
double y = 0;
double w = item.DesiredSize.Width;
double h = item.DesiredSize.Height;
if (!double.IsNaN(range))
{
if ((Orientation == Orientation.Horizontal))
w = ScaleToSize(range, arrangeSize.Width);
else
h = ScaleToSize(range, arrangeSize.Height);
}
Size size;
if (Orientation == Orientation.Horizontal)
{
x = ScaleToSize(pos, arrangeSize.Width);
size = new Size(w, arrangeSize.Height);
x -= SizeAdjustment(align, w);
}
else
{
y = ScaleToSize(pos, arrangeSize.Height);
size = new Size(arrangeSize.Width, h);
y -= SizeAdjustment(align, h);
}
return new Rect(new Point(x, y), size);
}
示例7: AddToValidControls
private static void AddToValidControls(UIElement element)
{
bool isTiltable = false;
bool isForcedSuppress = element.ReadLocalValue(SuppressTiltProperty) is bool && (bool) element.ReadLocalValue(SuppressTiltProperty);
if (!isForcedSuppress && TiltableItems.Any(t => TypeExtensions.IsTypeOf(element, t)))
{
isTiltable = true;
#if WINDOWS_STORE
element.PointerMoved += InitiateTiltEffect;
#elif WINDOWS_PHONE
element.ManipulationStarted += InitiateTiltEffect;
#endif
}
// hit a child with a tilt ability,
// having a control within a control having tilt is redundant
if (isTiltable)
return;
var children = element.GetVisualChildren();
foreach (var child in children)
{
AddToValidControls(child as FrameworkElement);
}
}