本文整理汇总了C#中System.Windows.FrameworkElement.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# FrameworkElement.GetType方法的具体用法?C# FrameworkElement.GetType怎么用?C# FrameworkElement.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.FrameworkElement
的用法示例。
在下文中一共展示了FrameworkElement.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDataContextSubscriptionMode
private static DataContextSubscriptionMode GetDataContextSubscriptionMode(FrameworkElement element)
{
var dependencyResolver = IoCConfiguration.DefaultDependencyResolver;
var dataContextSubscriptionService = dependencyResolver.Resolve<IDataContextSubscriptionService>();
return dataContextSubscriptionService.GetDataContextSubscriptionMode(element.GetType());
}
示例2: FrameworkElementWrapper
public FrameworkElementWrapper(FrameworkElement element, HereString hereString, FrameworkElementWrapper parent = null)
{
Element = element;
XamlDeclaration = hereString;
Icon = IconMappings.ContainsKey(element.GetType().Name)
? IconMappings[element.GetType().Name]
: IconMappings["Element"];
GenerateChildren();
Parent = parent;
EventMappings = new Dictionary<string, PsEventHandler>();
var events = element.GetType().GetEvents();
foreach (var eventInfo in events)
{
EventMappings.Add(eventInfo.Name, null);
}
}
示例3: CopyValues
internal void CopyValues( FrameworkElement element )
{
foreach( PropertyInfo prop in element.GetType().GetProperties() )
{
_originalValues.Add( prop.Name, prop.GetValue( element, null ) );
}
}
示例4: GenerateTypePath
public static List<TypeIndexAssociation> GenerateTypePath(FrameworkElement element)
{
List<TypeIndexAssociation> typePath = new List<TypeIndexAssociation>();
while (element != null)
{
int index = 0;
if (VisualTreeHelper.GetParent(element) != null)
{
DependencyObject parent = VisualTreeHelper.GetParent(element);
if (parent is Panel)
{
index = ((Panel)parent).Children.IndexOf(element);
}
}
typePath.Add(new TypeIndexAssociation() { ElementType = element.GetType(), Index = index });
element = VisualTreeHelper.GetParent(element) as FrameworkElement;
}
typePath.Reverse();
return typePath;
}
示例5: FindMissionUserControls
private void FindMissionUserControls(FrameworkElement frameworkElement, List<MissionUserControl> missionUserControls)
{
if (frameworkElement.GetType().IsSubclassOf(typeof(MissionUserControl)) || frameworkElement.GetType() == typeof(MissionUserControl))
{
missionUserControls.Add((MissionUserControl)frameworkElement);
}
//go through children
foreach (object logicalChild in LogicalTreeHelper.GetChildren(frameworkElement))
{
if (logicalChild.GetType().IsSubclassOf(typeof(FrameworkElement)))
{
FindMissionUserControls((FrameworkElement)logicalChild, missionUserControls);
}
}
}
示例6: GetViewCloseAction
private static Action GetViewCloseAction(object viewModel, FrameworkElement view, bool? dialogResult)
{
var viewType = view.GetType();
var closeMethod = viewType.GetMethod("Close");
if (closeMethod != null)
return () =>
{
var isClosed = false;
if (dialogResult != null)
{
var resultProperty = viewType.GetProperty("DialogResult");
if (resultProperty != null)
{
resultProperty.SetValue(view, dialogResult, null);
isClosed = true;
}
}
if (!isClosed)
{
closeMethod.Invoke(view, null);
}
};
return () => PiracRunner.GetLogger<Screen>().Info("TryClose requires a view with a Close method.");
}
示例7: FindElementRecursive
// 指定したタイプのUIElementを検索して返す
public static UIElement FindElementRecursive(FrameworkElement parent, Type targetType)
{
if (parent.GetType() == targetType)
{
return parent as UIElement;
}
int childCount = VisualTreeHelper.GetChildrenCount(parent);
UIElement returnElement = null;
if (childCount > 0)
{
for (int i = 0; i < childCount; i++)
{
Object element = VisualTreeHelper.GetChild(parent, i);
if (element.GetType() == targetType)
{
return element as UIElement;
}
else
{
returnElement = FindElementRecursive(VisualTreeHelper.GetChild(parent, i) as FrameworkElement, targetType);
}
}
}
return returnElement;
}
示例8: ColorViewModel
public ColorViewModel(FrameworkElement window)
{
Window = window;
cmdShow = new RoutedCommand();
CommandManager.RegisterClassCommandBinding(Window.GetType(), new CommandBinding(cmdShow, cmdShow_Click));
FillColors();
}
示例9: InitControlPrivider
public static IOrientationProvider InitControlPrivider(FrameworkElement control)
{
if (control == null)
return null;
if (ProviderCollection.Providers.ContainsKey(control.GetType()))
{
IOrientationProvider provider = typeof(IOrientationProvider).Assembly.CreateInstance(ProviderCollection.Providers[control.GetType()]) as IOrientationProvider;
return provider;
}
else
{
IOrientationProvider provider = new ElementOrientationProvider();//如果找不到对于的Provider 则使用默认元素Provider
return provider;
}
}
示例10: __UIElementCollection
public __UIElementCollection(FrameworkElement VisualParent)
{
var p = VisualParent as Panel;
if (p == null)
throw new Exception("VisualParent should be of type Panel instead of " + VisualParent.GetType().Name);
this.InternalVisualParent = VisualParent;
}
示例11: WriteElementToXml
private void WriteElementToXml(XmlWriter writer, FrameworkElement item)
{
if (item == null)
{
return;
}
writer.WriteStartElement(item.GetType().ToString());
var coordinates = item.GetCoordinatesInView(this.Automator.VisualRoot);
var rect = item.GetRect(this.Automator.VisualRoot);
var attributes = new Dictionary<string, string>
{
{ "name", item.AutomationName() },
{ "id", item.AutomationId() },
{ "xname", item.Name },
{
"visible",
item.IsUserVisible(this.Automator.VisualRoot)
.ToString()
.ToLowerInvariant()
},
{ "value", item.GetText() },
{ "x", rect.X.ToString(CultureInfo.InvariantCulture) },
{ "y", rect.Y.ToString(CultureInfo.InvariantCulture) },
{
"width",
rect.Width.ToString(CultureInfo.InvariantCulture)
},
{
"height",
rect.Height.ToString(CultureInfo.InvariantCulture)
},
{
"clickable_point",
coordinates.ToString(CultureInfo.InvariantCulture)
}
};
foreach (var attribute in attributes)
{
writer.WriteAttributeString(attribute.Key, attribute.Value);
}
var children = Finder.GetChildren(item);
if (item == this.Automator.VisualRoot)
{
children = children.Concat(Finder.GetPopupsChildren());
}
foreach (var child in children)
{
this.WriteElementToXml(writer, child as FrameworkElement);
}
writer.WriteEndElement();
}
示例12: AttachedBinding
public AttachedBinding(DependencyObject target, FrameworkElement attachTarget,
DependencyProperty bindingProperty, Type bindingType)
{
// basic checks
if (target == null) throw new ArgumentNullException("target");
if (attachTarget == null) throw new ArgumentNullException("attachTarget");
if (bindingProperty == null) throw new ArgumentNullException("bindingProperty");
if (bindingType == null) throw new ArgumentNullException("bindingType");
// we save the reference to the source
_target = new WeakReference(target);
_attachTarget = new WeakReference(attachTarget);
_bindingProperty = bindingProperty;
// we get the default value
object _defValue = bindingProperty.GetMetadata(bindingType).DefaultValue;
// we attach the dp
if (attachTarget != null)
{
// we create the attached property
_attachedProperty = DependencyProperty.RegisterAttached(string.Format(DP_NAME_FROMAT, _indexer++),
bindingType, attachTarget.GetType(),
new PropertyMetadata(_defValue,
OnPropertyChanged));
}
else
{
attachTarget.Loaded += (s, e) =>
{
// we create the binding property
_attachedProperty =
DependencyProperty.RegisterAttached(
string.Format(DP_NAME_FROMAT, _indexer++),
bindingType, attachTarget.GetType(),
new PropertyMetadata(_defValue, OnPropertyChanged));
// and we if have binding then
if (_binding != null) SetBinding(_binding);
};
}
}
示例13: Present
public override void Present(FrameworkElement frameworkElement)
{
// this is really hacky - do it using attributes isnt
var attribute = frameworkElement
.GetType()
.GetCustomAttributes(typeof (RegionAttribute), true)
.FirstOrDefault() as RegionAttribute;
var regionName = attribute == null ? null : attribute.Name;
_mainWindow.PresentInRegion(frameworkElement, regionName);
}
示例14: GetParentOfType
// gets the first ancestor of an element that matches a given type
public static object GetParentOfType(FrameworkElement e, Type type)
{
for (; e != null; e = VisualTreeHelper.GetParent(e) as FrameworkElement)
{
if (e.GetType().IsAssignableFrom(type))
{
return e;
}
}
return null;
}
示例15: RestoreValues
internal void RestoreValues( FrameworkElement element )
{
foreach( PropertyInfo prop in element.GetType().GetProperties() )
{
object o = _originalValues[prop.Name];
if( prop.CanWrite && o != prop.GetValue( element, null ) )
{
prop.SetValue( element, o, null );
}
}
}