Different TreeViewItem.Header for Branches and Leaves in a Bound TreeView


i trying write app show these points of data qa lab installer; rack (set of servers), server, project, branch, component, , build number. tell users software builds installed where. have written manually, want use data binding automatically pick updates our sql server.

treeview ui design looks this:
+ rack
--+ server
----+ project - branch - component - build number

with rack , server treeviewitems, header set string, final node, tree leaf, uses stackpanel, textblock each of 4 values; project, branch, component, , build number. there functionality have different colors different install states plus tooltip shows user started install, start time, , stop time. additionally, there mouse left-click event on final tree leaf show log particular install. need ability have tree branch , tree leaf nodes handled differently.

looking @ binding examples find, show bind string, know header can framework element. changed binding class use observablecollection have stackpanel property accessor rather string, when populating data can add textblock stackpanel if tree branch, or more complicated stackpanel described above if tree leaf.

ok, here's problem i'm having. don't know syntax bind stackpanel itemtemplate. i've found initial solution binding treeviewitem, ends wrapping treeviewitem in treeviewitem, shows in ui when point @ node highlight selection within highlight selection.

here's binding, header stackpanel:

<mwc:treeview.itemtemplate>
  <mwc:hierarchicaldatatemplate itemssource="{binding data, mode=oneway}">
    <mwc:treeviewitem header="{binding header, mode=oneway}"/>
  </mwc:hierarchicaldatatemplate>
</mwc:treeview.itemtemplate>

is there different element can use? want, though know doesn't work. need place binding in attribute of element, don't know one.

<mwc:treeview.itemtemplate>
  <mwc:hierarchicaldatatemplate itemssource="{binding data, mode=oneway}">
    {binding header, mode=oneway}
  </mwc:hierarchicaldatatemplate>
</mwc:treeview.itemtemplate>

i new binding, silverlight, , wpf, i'm sure i'm making harder needs be. tried moving binding code behind, couldn't quite figure out. hoping find property set, hanging off hierarchicaldatatemplate instance. don't quite understand resources (), examples saw didn't help.

can set multiple templates , select 1 based on whether binding class' observablecollection null or not, indicating tree leaf since there no children?

i looking different/better method of binding, either in xaml or code behind, allow me configure treeviewitem branch header differently treeviewitem leaf header when using binding.

thank pointers or on this!

found solution in silverlight examples of places. doh!

http://silverlight.net/samples/sl2/toolkitcontrolsamples/run/default.html

then click on treeview in left navigation bar, on "nested hierarchicaldatatemplate" in top navigation bar.



Silverlight  >  Programming Silverlight with .NET – General



Comments

Popular posts from this blog

Conditional formatting a graph vertical axis in SSRS 2012 charts

Register with Power BI failed

SQL server replication error Cannot find the dbo or user defined function........