本文整理汇总了C#中System.Windows.Controls.TreeViewItem.ExpandSubtree方法的典型用法代码示例。如果您正苦于以下问题:C# TreeViewItem.ExpandSubtree方法的具体用法?C# TreeViewItem.ExpandSubtree怎么用?C# TreeViewItem.ExpandSubtree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.TreeViewItem
的用法示例。
在下文中一共展示了TreeViewItem.ExpandSubtree方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainWindow
public MainWindow(ICatalogManager catMgr, IFinancialManager finMgr)
{
InitializeComponent();
_catMgr = catMgr;
_finMgr = finMgr;
var root = new TreeViewItem();
root.Header = "Tree";
var child = new TreeViewItem();
child.Header = "Initial Data Typing";
root.Items.Add(child);
child = new TreeViewItem();
child.Header = "Descriptions";
root.Items.Add(child);
MainTreeView.Items.Add(root);
root.ExpandSubtree();
AreaComboBox.AddHandler(TextBoxBase.TextChangedEvent,
new TextChangedEventHandler(ComboBox_TextChanged));
}
示例2: ToTreeViewItem
public static TreeViewItem ToTreeViewItem(this ProjectModel project)
{
var node = new TreeViewItem { Header = project.Name };
if (!project.AllChildrenExist)
node.ExpandSubtree();
return node;
}
示例3: button_Click
//private static void ProcessNode(HtmlNode node, Stack<HtmlNode> stack)
//{
// var depth = stack.Count;
// var padding = String.Empty.PadLeft(depth, ' ');
// stack.Push(node);
// try
// {
// Debug.WriteLine(padding + "Node: " + node.Name);
// foreach (var child in node.ChildNodes)
// {
// ProcessNode(child, stack);
// }
// }
// finally
// {
// stack.Pop();
// }
//}
private void button_Click(object sender, RoutedEventArgs e)
{
using (var stream = File.OpenRead(@"C:\Documents\bookmarks_7_27_15.html"))
{
var doc = new HtmlDocument();
doc.Load(stream);
var rootFolder = new Folder { Name = "<root>" };
ProcessNode(doc.DocumentNode, rootFolder);
if (rootFolder.Folders.Count == 1)
rootFolder = rootFolder.Folders.Single();
treeView.Items.Add(GetTree(rootFolder));
var bookmarks = rootFolder.AllBookmarks.ToList();
bookmarks.Sort(
(l, r) => StringComparer.OrdinalIgnoreCase.Compare(l.Href.ToString(), r.Href.ToString()));
var lookupItem = new TreeViewItem { Header = "Lookup" };
var lookup = rootFolder.AllBookmarks.ToLookup(b => b.Href.ToString(), b => b.Folder, StringComparer.OrdinalIgnoreCase);
foreach (var key in lookup)
{
var folders = new HashSet<string>(key.Select(k => k.FullName), StringComparer.OrdinalIgnoreCase);
if (folders.Count > 1)
{
//folders.Sort((l, r) => StringComparer.OrdinalIgnoreCase.Compare(l.FullName, r.FullName));
var keyItem = new TreeViewItem { Header = key.Key + " (" + folders.Count + ")" };
foreach (var folder in folders.OrderBy(f => f, StringComparer.OrdinalIgnoreCase))
keyItem.Items.Add(new TreeViewItem { Header = folder });
lookupItem.Items.Add(keyItem);
}
}
lookupItem.ExpandSubtree();
treeView.Items.Add(lookupItem);
var set = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
foreach (var bookmark in rootFolder.AllBookmarks)
set.Add(bookmark.ToString());
foreach (var txt in set)
Debug.WriteLine(txt);
using (var output = File.OpenWrite(@"C:\Documents\output.html"))
{
output.SetLength(0);
using (var writer = new StreamWriter(output))
{
writer.WriteLine(@"<!DOCTYPE NETSCAPE-Bookmark-file-1>");
writer.WriteLine(@"<!-- This is an automatically generated file.");
writer.WriteLine(@" It will be read and overwritten.");
writer.WriteLine(@" DO NOT EDIT! -->");
writer.WriteLine(
"<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html;charset=UTF-8\">");
writer.WriteLine(@"<TITLE>Bookmarks</TITLE>");
WriteFolder(rootFolder, writer, new HashSet<string>(StringComparer.OrdinalIgnoreCase), "");
}
}
//Debugger.Break();
}
}
示例4: MainWindow
public MainWindow(ICatalogManager catMgr, IFinancialManager finMgr)
{
InitializeComponent();
_catMgr = catMgr;
_finMgr = finMgr;
var root = new TreeViewItem();
root.Header = "Tree";
var child = new TreeViewItem();
child.Header = "Initial Data Typing";
child.Selected += TreeViewItemSelected;
child.Tag = typeof(InitialDataTypingView);
root.Items.Add(child);
child = new TreeViewItem();
child.Header = "Descriptions";
child.Selected += TreeViewItemSelected;
child.Tag = typeof(DescriptionView);
root.Items.Add(child);
MainTreeView.Items.Add(root);
root.ExpandSubtree();
}
示例5: AddLayer
private void AddLayer(Layer layer)
{
Type layerClassType = layer.GetType();
TreeViewItem newItem = new TreeViewItem();
newItem.Header = Layer.LayerTypes[layerClassType];
newItem.Tag = layer;
foreach (var p in layerClassType.GetProperties())
{
var property = p; // we want to closure this value in lambdas - therefore there must be an additional variable - do not use the foreach variable p!
LayerAttributes.LayerAttribute[] layerAttributeList = (LayerAttributes.LayerAttribute[])
property.GetCustomAttributes(typeof(LayerAttributes.LayerAttribute), false);
if (layerAttributeList.Length > 0)
{
// create ui for this element
layerAttributeList[0].CreateTreeViewSubElement(newItem, (int)Layers.ActualWidth,
() => { return property.GetMethod.Invoke(layer, new object[0]); },
(value) => { property.SetMethod.Invoke(layer, new object[] { value }); });
// pointset layer must be registered
if (layerAttributeList[0] is LayerAttributes.LayerAttributePointSet)
terrainRenderingPreview.AddPointSet((PointSet)property.GetMethod.Invoke(layer, new object[0]));
}
}
if (Layers.Items.IsEmpty || (Layers.SelectedItem == null))
Layers.Items.Insert(0, newItem);
else
Layers.Items.Insert(Layers.Items.IndexOf(Layers.SelectedItem), newItem);
newItem.ExpandSubtree();
newItem.IsSelected = true;
}
示例6: ShowObject
public void ShowObject(BsonValue bsonValue)
{
var tree = new TreeView();
var item = new TreeViewItem();
tree.Items.Add(item);
WriteObject(item, bsonValue);
item.ExpandSubtree();
this.Content = tree;
Show();
Focus();
this.Topmost= true;
}
示例7: ExceptionMessageBox
public ExceptionMessageBox(System.Exception e, string userExceptionMessage)
{
InitializeComponent();
this._userExceptionMessage = userExceptionMessage;
textBox1.Text = userExceptionMessage;
TreeViewItem treeViewItem = new TreeViewItem();
treeViewItem.Header = "Exception";
treeViewItem.ExpandSubtree();
buildTreeLayer(e, treeViewItem);
treeView1.Items.Add(treeViewItem);
}
示例8: MainWindow
public MainWindow()
{
InitializeComponent();
var root = new TreeViewItem();
root.Header = "Tree";
var child = new TreeViewItem();
child.Header = "Initial Data Typing";
root.Items.Add(child);
child = new TreeViewItem();
child.Header = "Descriptions";
root.Items.Add(child);
MainTreeView.Items.Add(root);
root.ExpandSubtree();
}
示例9: ExplanationView
public ExplanationView(IEnumerable<AutoCompletionResult.CommandResult> commandResults)
{
InitializeComponent();
foreach (var commandResult in commandResults)
{
var commandTreeItem = new TreeViewItem {Header = commandResult.Item.Text + commandResult.CompletionId};
Action<TreeViewItem, Explanation> renderExplanation = null;
renderExplanation = (t, exp) =>
{
var header = exp.Value + " " + exp.Description + " ";
var childItem = new TreeViewItem {Header = header};
t.Items.Add(childItem);
foreach (var explanation in exp.GetDetails() ?? new Explanation[] {})
{
renderExplanation(childItem, explanation);
}
};
renderExplanation(commandTreeItem, commandResult.Explanation);
commandTreeItem.ExpandSubtree();
ExplanationTree.Items.Add(commandTreeItem);
}
}
示例10: MainWindow
public MainWindow(ICatalogManager catMgr)
{
InitializeComponent();
_catMgr = catMgr;
var root = new TreeViewItem();
root.Header = "Tree";
var child = CreateTreeViewItem("Initial Data Typing");
child.Tag = typeof(InitialDataTypingForm);
root.Items.Add(child);
child = CreateTreeViewItem("Descriptions");
child.Tag = typeof(DescriptionsForm);
root.Items.Add(child);
MainTreeView.Items.Add(root);
root.ExpandSubtree();
AreaComboBox.AddHandler(TextBoxBase.TextChangedEvent,
new TextChangedEventHandler(ComboBox_TextChanged));
}
示例11: Group
void Group()
{
GroupTree.Items.Clear();
Results.Visibility = Visibility.Collapsed;
GroupTree.Visibility = Visibility.Visible;
if (Query.Text == string.Empty || DataToQuery.Text == string.Empty)
return;
try
{
Regex theExpr;
try
{
theExpr = new Regex(Query.Text, RegExOptions, Timeout);
}
catch (RegexMatchTimeoutException)
{
Status.Content = QueryTime.Content = "Timeout";
return;
}
catch (Exception E)
{
Status.Content = E.Message;
return;
}
var c = theExpr.Matches(DataToQuery.Text);
foreach (Match match in c)
{
var header = new TreeViewItem { Header = match.Value };
foreach (var groupName in theExpr.GetGroupNames())
{
var theGroup = match.Groups[groupName];
if (groupName == "0")
continue;
var groupHeader = new TreeViewItem { Header = "<" + groupName + "> " + theGroup };
header.Items.Add(groupHeader);
foreach (Capture theCapture in theGroup.Captures)
groupHeader.Items.Add(theCapture.Value);
}
GroupTree.Items.Add(header);
header.ExpandSubtree();
}
Status.Content = c.Count == 0 ? "No Matches" : "Matched";
}
catch (Exception e) { Status.Content = e.Message; }
}
示例12: Setup
//.........这里部分代码省略.........
if (!(cursor is TreeViewItem))
{
Controller.saved_repository = ((SelectionTreeItem)treeViewItem.Tag).repository;
}
}
// Load sub-folders if it has not been done already.
// We use each item's Tag to store metadata: whether this item's subfolders have been loaded or not.
if (((SelectionTreeItem)item.Tag).childrenLoaded == false)
{
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
// Get list of subfolders (asynchronously)
GetSubfoldersDelegate dlgt = new GetSubfoldersDelegate(CmisUtils.GetSubfolders);
IAsyncResult ar = dlgt.BeginInvoke(Controller.saved_repository,
Controller.saved_remote_path, Controller.saved_address.ToString(),
Controller.saved_user, Controller.saved_password, null, null);
while (!ar.AsyncWaitHandle.WaitOne(100))
{
System.Windows.Forms.Application.DoEvents();
}
string[] subfolders = dlgt.EndInvoke(ar);
// Create a sub-item for each subfolder
foreach (string subfolder in subfolders)
{
System.Windows.Controls.TreeViewItem subItem =
new System.Windows.Controls.TreeViewItem();
subItem.Tag = new SelectionTreeItem(null, subfolder);
subItem.Header = Path.GetFileName(subfolder);
item.Items.Add(subItem);
}
((SelectionTreeItem)item.Tag).childrenLoaded = true;
item.ExpandSubtree();
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
}
};
Button cancel_button = new Button()
{
Content = Properties_Resources.Cancel
};
Button continue_button = new Button()
{
Content = CmisSync.Properties_Resources.ResourceManager.GetString("Continue", CultureInfo.CurrentCulture)
};
Button back_button = new Button()
{
Content = Properties_Resources.Back,
IsDefault = false
};
Buttons.Add(back_button);
Buttons.Add(continue_button);
Buttons.Add(cancel_button);
continue_button.Focus();
cancel_button.Click += delegate
{
Controller.PageCancelled();
};
continue_button.Click += delegate
示例13: SparkleSetup
//.........这里部分代码省略.........
// Identify the selected repository.
object cursor = item;
while (cursor is TreeViewItem)
{
TreeViewItem treeViewItem = (TreeViewItem)cursor;
cursor = treeViewItem.Parent;
if ( ! (cursor is TreeViewItem))
{
Controller.saved_repository = (string)treeViewItem.Header;
}
}
// Load sub-folders if it has not been done already.
// We use each item's Tag to store metadata: whether this item's subfolders have been loaded or not.
if ( ((SelectionTreeItem)item.Tag).childrenLoaded == false)
{
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
// Get list of subfolders
string[] subfolders = CmisUtils.GetSubfolders(Controller.saved_repository, Controller.saved_remote_path,
Controller.saved_address, Controller.saved_user, Controller.saved_password);
// Create a sub-item for each subfolder
foreach (string subfolder in subfolders)
{
System.Windows.Controls.TreeViewItem subItem =
new System.Windows.Controls.TreeViewItem();
subItem.Tag = new SelectionTreeItem(subfolder);
subItem.Header = Path.GetFileName(subfolder);
item.Items.Add(subItem);
}
((SelectionTreeItem)item.Tag).childrenLoaded = true;
item.ExpandSubtree();
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
}
};
Button cancel_button = new Button()
{
Content = "Cancel"
};
Button add_button = new Button()
{
Content = "Add"
};
Buttons.Add(add_button);
Buttons.Add(cancel_button);
cancel_button.Click += delegate
{
Controller.PageCancelled();
};
add_button.Click += delegate
{
Controller.Add2PageCompleted(
Controller.saved_repository, Controller.saved_remote_path);
};
break;
}
case PageType.Syncing: {
示例14: UpdateCacheView
private void UpdateCacheView()
{
cacheDirectoryTextBox.Text = Cache.CacheDirectory;
cacheTreeView.Items.Clear();
//show error if cache not detected
if (!File.Exists(Cache.CacheDirectory + Cache.CacheFileName))
{
cacheTreeView.Items.Add("No cache file found in directory.");
_canExtract = false;
return;
}
//fill the treeview
var cacheTreeItem = new TreeViewItem
{
Header = "Cache",
Tag = -1,
ContextMenu = (ContextMenu)Resources["ExtractContextMenu"]
};
cacheTreeItem.MouseDoubleClick += cacheTreeViewItem_DoubleClick;
cacheTreeItem.ExpandSubtree();
foreach (var archiveId in Cache.GetArchiveIds())
{
var archiveTreeItem = new TreeViewItem
{
Header = $"Archive {archiveId}",
Tag = archiveId,
ContextMenu = (ContextMenu)Resources["ExtractContextMenu"]
};
archiveTreeItem.MouseDoubleClick += cacheTreeViewItem_DoubleClick;
cacheTreeItem.Items.Add(archiveTreeItem);
}
_canExtract = true;
cacheTreeView.Items.Add(cacheTreeItem);
}
示例15: ShowFormula
private void ShowFormula(string cellRef, string formula)
{
var formulaObject = new ExcelFormulaParser.ExcelFormula(formula);
System.Action action = () =>
{
FormulaTreeView.Items.Clear();
var rootItem = new TreeViewItem {Header = cellRef};
FormulaTreeView.Items.Add(rootItem);
ShowFormula(new Queue<ExcelFormulaToken>(formulaObject), rootItem.Items);
rootItem.ExpandSubtree();
};
Dispatcher.BeginInvoke(action);
}