hierarchicaldatatemplate

Any way to use interfaces with wpf HierarchicalDataTemplate

£可爱£侵袭症+ 提交于 2019-12-11 00:00:01
问题 Hi I am using an interface IFooNode, which is part of a tree. I wanted to display this tree in a TreeView using a HierarchicalDataTemplate. This however does not work due to the interface. I see two ways around that neither are what I would call "nice" Find out what type really implements IFooNode (let's call it FooNode...), then find the assembly defining FooNode, add a Reference to that assembly and create a HierarchicalDataTemplate for FooNode (hoping the Implementating class never changes

How to display JSON in WPF TreeView

拈花ヽ惹草 提交于 2019-12-09 23:53:31
问题 I am reading in JSON and then displaying it in a WPF treeview. Here is the code... Class MainWindow Public Sub New() InitializeComponent() Dim dic = GetThreadedObject(GetJASN())("phases") Dim items = dic(0) tView.ItemsSource = items End Sub Private Function GetJASN() As String Dim output As String = My.Computer.FileSystem.ReadAllText(My.Application.Info.DirectoryPath & "\UAL525 Phase of Flight.json") Return output End Function Private Function GetThreadedObject(JASN As String) Dim Js As New

WPF TreeView hierarchical binding.

寵の児 提交于 2019-12-09 06:54:15
问题 just starting with wpf. I need to bind the object (Hierarchical) Folder public class Folder { public Folder() { this.Name = string.Empty; this.Modules = new ObservableCollection<Module>(); this.Folders = new List<Folder>(); this.HasChild = false; } public Folder(Folder parent) { this.Name = string.Empty; this.Modules = new ObservableCollection<Module>(); this.Folders = new List<Folder>(); this.HasChild = false; this.Parent = parent; } public bool HasChild { get; set; } public string Name {

WPF HierarchicalDataTemplate treeview

非 Y 不嫁゛ 提交于 2019-12-08 12:22:39
问题 I have some objects I would like to display using a TreeView . The classes I use are defined like this: public abstract class QueryPart { private static Random _random; protected static Random Random { get { return _random??(_random=new Random(654)); } } public string Name { get; set; } public QueryPart() { this.Name = this.GetType().Name + " " + Random.Next(); } } public abstract class Criterium : QueryPart { object ParamValue { get; set; } protected Criterium() { ParamValue = Random.Next();

get item from treeView c#

自闭症网瘾萝莉.ら 提交于 2019-12-08 04:20:06
问题 I have a TreeView <TreeView Name="files" Margin="0,0,569,108" Grid.Row="1" ItemsSource="{Binding s1}"> <TreeView.ItemTemplate> <HierarchicalDataTemplate ItemsSource="{Binding Members}" > <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Name}" /> </StackPanel> <HierarchicalDataTemplate.ItemTemplate> <DataTemplate> <CheckBox Name="CheckBox111" Checked="FileCheckBox_Checked" Unchecked="FileCheckBox_Unchecked"> <ContentPresenter> <ContentPresenter.Content> <StackPanel Orientation=

Hierarchical templating multiple object types in silverlight

我怕爱的太早我们不能终老 提交于 2019-12-07 19:14:52
问题 Is it possible and if so what is the best way to implement the following hierarchical structure in a silverlight (4) TreeView control? (where Item and Group are classes which can exist in the tree). Group | |-Item | |-Group | | | |-Item | | | |-Item | |-Item The structure could of course be arbitrarily more complex than this, if needed. HierarchicalDataTemplates appear to be the way to approach this, but I'm specifically having trouble understanding how I might apply the template to interpret

Hierarchical templating multiple object types in silverlight

蹲街弑〆低调 提交于 2019-12-06 10:15:02
Is it possible and if so what is the best way to implement the following hierarchical structure in a silverlight (4) TreeView control? (where Item and Group are classes which can exist in the tree). Group | |-Item | |-Group | | | |-Item | | | |-Item | |-Item The structure could of course be arbitrarily more complex than this, if needed. HierarchicalDataTemplates appear to be the way to approach this, but I'm specifically having trouble understanding how I might apply the template to interpret the different classes correctly. A similar question was asked for WPF, the answer for which made use

How can I have multiple types of children in a single Silverlight TreeView node?

泪湿孤枕 提交于 2019-12-05 10:22:26
Short Vesion: I have to display a hierarchy ( TreeView ) of items of different types, and am not sure how to do this cleanly in Silverlight. In WPF, it's straightforward to define templates ( HierarchicalDataTemplate ) based on types, but this feature isn't available in Silverlight. It seems in Silverlight you have to apply the same template to all children of a specific node, so you end up with once single monster template that handles every possible type of node, applied to every single node. Long Version (with example): To give a more concrete (but contrived) example, consider a treeview of

How to display JSON in WPF TreeView

我的未来我决定 提交于 2019-12-04 20:01:14
I am reading in JSON and then displaying it in a WPF treeview. Here is the code... Class MainWindow Public Sub New() InitializeComponent() Dim dic = GetThreadedObject(GetJASN())("phases") Dim items = dic(0) tView.ItemsSource = items End Sub Private Function GetJASN() As String Dim output As String = My.Computer.FileSystem.ReadAllText(My.Application.Info.DirectoryPath & "\UAL525 Phase of Flight.json") Return output End Function Private Function GetThreadedObject(JASN As String) Dim Js As New JavaScriptSerializer() Js.MaxJsonLength = JASN.Length * 2 Dim j = Js.Deserialize(Of Object)(JASN) Return

How do I reuse a HierarchicalDataTemplate?

心已入冬 提交于 2019-12-04 15:36:22
I have two identical HierarchicalDataTemplates. The only difference is the DataType of the templates. <HierarchicalDataTemplate DataType="{x:Type Data:OuterType}" ItemsSource="{Binding Items}"> <StackPanel>...</StackPanel> </HierarchicalDataTemplate> <HierarchicalDataTemplate DataType="{x:Type Data:InnerType}" ItemsSource="{Binding Items}"> <StackPanel>...</StackPanel> </HierarchicalDataTemplate> How can I avoid duplicating the contents of the stack panel in both data templates? I considered making the StackPanel into a user control, but this is the only place that control would ever be used.