Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I am not sure exactly what you are looking for. I assume resultsTreeView is a TreeViewItem. and I also assume that you are working in wpf. You can do the following through wpf.</p> <pre><code>for (int i = 0; i &lt; lines.Count(); i++) { resultsTreeView.Items.Add(lines[i].ToString().Substring(67,17)); } &lt;TreeView x:Name="resultsTreeView" HorizontalAlignment="Left" Height="100" Margin="37,344,0,0" VerticalAlignment="Top" Width="257" &gt; &lt;TreeView.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;TextBlock Text="{Binding}"/&gt; &lt;CheckBox/&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/TreeView.ItemTemplate&gt; &lt;/TreeView&gt; </code></pre> <p>Something similar could be done through code behind</p> <pre><code>for (int i = 0; i &lt; mylist.Count(); i++) { resultsTreeView.Items.Add(mylist[i]); } resultsTreeView.ItemTemplate = TreeViewDataTemp; </code></pre> <p>And then create TreeViewDataTemp the following way</p> <pre><code>private static DataTemplate TreeViewDataTemp { get { DataTemplate TVDT = new DataTemplate(); FrameworkElementFactory Stack = new FrameworkElementFactory(typeof(StackPanel)); Stack.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal); FrameworkElementFactory TextB = new FrameworkElementFactory(typeof(TextBlock)); TextB.SetValue(TextBlock.TextProperty, new Binding()); FrameworkElementFactory ChkBox = new FrameworkElementFactory(typeof(CheckBox)); Stack.AppendChild(TextB); Stack.AppendChild(ChkBox); TVDT.VisualTree = Stack; return TVDT; } } </code></pre> <p>The above gives you 1 item which is text together with a checkbox. Alternatively your method will add a checkbox as a new item after every string item that you add.. which is</p> <pre><code>for (int I=0; I&lt;lines.Count(); I++) { resultsTreeView.Items.Add(mylist[i]); resultsTreeView.Items.Add(new CheckBox()); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload