本文整理汇总了C#中System.Windows.UIElement.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# UIElement.GetType方法的具体用法?C# UIElement.GetType怎么用?C# UIElement.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.UIElement
的用法示例。
在下文中一共展示了UIElement.GetType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsSubClassOf
private bool IsSubClassOf(UIElement ui, Type type)
{
while (null != ui)
{
if ((ui.GetType() == type) ||
(ui.GetType().IsSubclassOf(type)))
{
return true;
}
ui = VisualTreeHelper.GetParent(ui) as UIElement;
}
return false;
}
示例2: AttachCore
protected override void AttachCore(UIElement element)
{
if (description == null)
{
string str = element.GetType().Name;
description = str;
}
}
示例3: InitializeView
private void InitializeView(UIElement view) {
var type = view.GetType();
var initializeMethod = type.GetMethod("InitializeComponent", BindingFlags.Public | BindingFlags.Instance);
if (initializeMethod == null)
return;
initializeMethod.Invoke(view, null);
}
示例4: AnimateColor
public static void AnimateColor(SolidColorBrush from, SolidColorBrush to, UIElement control, double duration)
{
SolidColorBrush myBrush = new SolidColorBrush();
myBrush = from;
ColorAnimation myColorAnimation = new ColorAnimation();
myColorAnimation.From = from.Color;
myColorAnimation.To = to.Color;
myColorAnimation.Duration = new Duration(TimeSpan.FromSeconds(duration));
myBrush.BeginAnimation(SolidColorBrush.ColorProperty, myColorAnimation);
control.GetType().GetProperty("Background").SetValue(control, myBrush);
}
示例5: CreateWrapperForUIElement
internal static IEditable CreateWrapperForUIElement(CanvasEditor editor, UIElement element)
{
IEditable result = null;
Assembly assembly = Assembly.GetAssembly(typeof(EditableWrapper));
string name = element.GetType().Name;
Type type = assembly.GetType(typeof(EditableWrapper).Namespace + ".Editable" + name);
if (type != null)
{
result = (IEditable)Activator.CreateInstance(type, new object[] { editor, element });
}
return result;
}
示例6: FindByName
private void FindByName(UIElement element, List<WildcardPattern> patterns, ref List<UIElement> results)
{
foreach (string content in _contentProperties)
{
Type type = element.GetType();
var prop = type.GetProperty(content);
if (prop != null)
{
var enumerable = prop.GetValue(element, null) as System.Collections.IEnumerable;
if (enumerable != null)
{
foreach (object el in enumerable)
{
var fel = el as FrameworkElement;
if (fel != null)
{
foreach (var pattern in patterns)
{
if (pattern.IsMatch(fel.Name))
{
results.Add(fel);
}
}
}
}
foreach (object el in enumerable)
{
if (el is UIElement)
{
FindByName((UIElement)el, patterns, ref results);
}
}
}
else
{
var el = prop.GetValue(element, null) as UIElement;
if (el != null)
{
var fel = el as FrameworkElement;
if (fel != null)
{
foreach (var pattern in patterns)
{
if (pattern.IsMatch(fel.Name))
{
results.Add(fel);
}
}
FindByName(fel, patterns, ref results);
}
else
{
FindByName(el, patterns, ref results);
}
}
}
}
// if we didn't find it by now, just give up...
}
}
示例7: RegisterEvent
private void RegisterEvent(UIElement element, string triggerEvent)
{
var eventRef = element.GetType().GetEvent(triggerEvent);
if (eventRef != null)
{
var invokeMethod = eventRef.EventHandlerType.GetMethod("Invoke");
var parameters = invokeMethod.GetParameters();
if (parameters.Length == 2)
{
if (typeof(RoutedEventArgs).IsAssignableFrom(parameters[1].ParameterType))
{
eventRef.AddEventHandler(element, new RoutedEventHandler(InvokeProvider));
}
else if (typeof(EventArgs).IsAssignableFrom(parameters[1].ParameterType))
{
eventRef.AddEventHandler(element, new EventHandler(InvokeProvider));
}
}
}
}
示例8: InvalidOperationException
void IViewAware.AttachView(UIElement view)
{
if (this.View != null)
throw new InvalidOperationException(String.Format("Tried to attach View {0} to ViewModel {1}, but it already has a view attached", view.GetType().Name, this.GetType().Name));
this.View = view;
this.logger.Info("Attaching view {0}", view);
var viewAsFrameworkElement = view as FrameworkElement;
if (viewAsFrameworkElement != null)
{
if (viewAsFrameworkElement.IsLoaded)
this.OnViewLoaded();
else
viewAsFrameworkElement.Loaded += (o, e) => this.OnViewLoaded();
}
}