本文整理汇总了C#中System.Windows.DependencyObject.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# DependencyObject.ToString方法的具体用法?C# DependencyObject.ToString怎么用?C# DependencyObject.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.DependencyObject
的用法示例。
在下文中一共展示了DependencyObject.ToString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowVisualTree
void ShowVisualTree(DependencyObject dObject)
{
sb.Append(dObject.ToString());
sb.Append(Environment.NewLine);
if (VisualTreeHelper.GetChildrenCount(dObject) > 0)
{
for (Int32 i = 0; i < VisualTreeHelper.GetChildrenCount(dObject); i++)
{
ShowVisualTree(VisualTreeHelper.GetChild(dObject, i));
}
}
}
示例2: DumpTree
void DumpTree (DependencyObject root, StringBuilder builder)
{
builder.AppendFormat (string.Format ("{0}", root.ToString()));
if (VisualTreeHelper.GetChildrenCount (root) > 0) {
builder.Append (" -> { \n");
for (int i = 0; i < VisualTreeHelper.GetChildrenCount (root); i ++) {
DumpTree (VisualTreeHelper.GetChild (root, i), builder);
if (i < VisualTreeHelper.GetChildrenCount (root) - 1)
builder.Append (",\n");
}
builder.Append (" }");
}
}
示例3: SetSelectedItemStyle
/// <summary>
/// Sets the SelectedItemStyle property. This dependency property
/// indicates what style is to be used on a selected item.
/// </summary>
public static void SetSelectedItemStyle(DependencyObject d, Style value)
{
if (!(d is ListBox))
throw new InvalidCastException(d.ToString() + " is no ListBox");
var lb = (ListBox)d;
if (GetSelectedItemStyle(d) == null)
lb.SelectionChanged += new SelectionChangedEventHandler(lb_SelectionChanged);
else if (value == null)
lb.SelectionChanged -= new SelectionChangedEventHandler(lb_SelectionChanged);
d.SetValue(SelectedItemStyleProperty, value);
}
示例4: ShowLogicTree
void ShowLogicTree(DependencyObject dObject)
{
sb.Append(dObject.ToString());
sb.Append(Environment.NewLine);
foreach (Object d in LogicalTreeHelper.GetChildren(dObject))
{
if (d is DependencyObject)
{
ShowLogicTree(d as DependencyObject);
}
else
{
sb.Append(d.ToString());
sb.Append(Environment.NewLine);
}
}
}
示例5: PropertyChangedCallback
private static void PropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
{
dependencyObject.ToString();
}
示例6: GetParentWindow
private Window GetParentWindow(DependencyObject o)
{
DependencyObject parent = VisualTreeHelper.GetParent(o);
if (parent == null)
{
FrameworkElement fe = o as FrameworkElement;
if (fe != null)
{
if (fe is Window)
{
return fe as Window;
}
else if (fe.Parent != null)
{
return GetParentWindow(fe.Parent);
}
}
throw new ApplicationException("A window parent could not be found for " + o.ToString());
}
else
{
return GetParentWindow(parent);
}
}
示例7: BuildBackLogicalTree
void BuildBackLogicalTree(DependencyObject root)
{
if (root == null) return;
Debug.Write(" - " + String.Format("[{0}]{1}", root.ToString(), (root is FrameworkElement) ? (root as FrameworkElement).Name : ""));
var parent = LogicalTreeHelper.GetParent(root);
BuildBackLogicalTree(parent as DependencyObject);
}
示例8: BuildLogicalTree
void BuildLogicalTree(DependencyObject root, TreeViewItem item)
{
TreeViewItem newItem = new TreeViewItem();
newItem.Header = String.Format("[{0}]{1}", root.ToString(), (root is FrameworkElement)?(root as FrameworkElement).Name:"");
newItem.Tag = root;
if(item!=null)
{
item.Items.Add(newItem);
}
else
{
logicalTreeView.Items.Add(newItem);
}
var children = LogicalTreeHelper.GetChildren(root);
foreach (var child in children)
{
if (child is DependencyObject)
{
BuildLogicalTree(child as DependencyObject, newItem);
}
}
}
示例9: CheckLogicalTree
void CheckLogicalTree(DependencyObject root)
{
var children = LogicalTreeHelper.GetChildren(root);
foreach (var child in children)
{
if (child is DependencyObject)
{
if (LogicalTreeHelper.GetParent(child as DependencyObject) != root)
{
Debug.WriteLine(string.Format("Incorrect logical parent in element - {0} in {1}", child.ToString(), root.ToString()));
}
CheckLogicalTree(child as DependencyObject);
}
}
}
示例10: CheckItem
private static bool CheckItem(ItemCollection items, DependencyObject item)
{
// See http://www.codeproject.com/KB/menus/WPFMergeMenu.aspx?msg=3827921#xx3827921xx
foreach (var piece in items)
{
string pstr = piece.ToString();
string istr = item.ToString();
if (pstr == istr)
{
return true;
}
}
return false;
}