Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF: Treeview Item Root uses different template then child nodes
    primarykey
    data
    text
    <p>I currently am trying to bind my business object to a treeview as the root. And its collection property as the child. [I want to achieve this via BINDING]</p> <p>Something like this.</p> <pre><code>public object MyBusinessObject { private int _number; private bool _isSelected; private ObservableCollection&lt;AnotherObject&gt; _other = new ObservableCollection&lt;AnotherObject&gt;(); public int Number { get {return _number;} set {_number = value;}} public bool IsSelected{ get {return _isSelected;} set {_isSelected= value;}} public ObservableCollection&lt;AnotherObject&gt; Children { get {return _other;}} } </code></pre> <p>I want my treeview to be represented like this:</p> <ul> <li>"CheckBox binded to IsSelected" "Text binded to Number" <ul> <li>List of child binded to my "Children"</li> <li>List of child binded to my "Children"</li> <li>List of child binded to my "Children"</li> </ul></li> <li>"CheckBox binded to IsSelected" "Text binded to Number" <ul> <li>List of child binded to my "Children"</li> <li>List of child binded to my "Children"</li> <li>List of child binded to my "Children"</li> </ul></li> </ul> <p>I have no idea how to do this in xaml:</p> <pre><code> &lt;TreeView x:Name="_tv" ItemsSource="{Binding Path=MyBusinessObject}" &gt; &lt;TreeView.Resources&gt; &lt;HierarchicalDataTemplate&gt; &lt;CheckBox Content="{Binding Path=Number} IsChecked="{Binding Path=IsSelected}" /&gt; &lt;/HierarchicalDataTemplate&gt; &lt;HierarchicalDataTemplate ItemsSource="{Binding Path=Children}"&gt; &lt;TextBlock Text="{Binding Path=Name}" /&gt; &lt;/HierarchicalDataTemplate&gt; &lt;/TreeView.Resources&gt; &lt;/TreeView&gt; </code></pre> <p>I know the above is not right, but i was wondering if there is a way to do this properly.</p> <p>Thanks and Regards,</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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