1

I was doing this design:

How can I model this class in a database?

But I'm doing that in WPF. I'm a bit confused about how to create an interface WPF to add the objectives. I mean, only the interface (program design) to model the link problem.

RESULT:

<TreeView Name="treeView1">
    <TreeView.ItemTemplate>
        <HierarchicalDataTemplate DataType="{x:Type data:Objective}" ItemsSource="{Binding Path=Objectives}" >
            <TextBlock Text="{Binding Name}" />
        </HierarchicalDataTemplate>
    </TreeView.ItemTemplate>
</TreeView>
Community
  • 1
  • 1
oscar.fimbres
  • 1,145
  • 1
  • 13
  • 24
  • You mean the foreign key issue? – H.B. Aug 16 '11 at 03:10
  • Not exactly. I mean, I'm gonna create categories and sub categories in the program. I plan to deal with data Grid control and several dataGridDetails. I want to hear some ideas to do a good interface or UI design in WPF. Do I make myself clear? – oscar.fimbres Aug 16 '11 at 03:15
  • Maybe others think use treeView is better – oscar.fimbres Aug 16 '11 at 03:25
  • A `TreeView` control with a custom `ItemContainerStyle` would most likely be the easiest solution. However, if you wanted to be able to edit the data inline, you could also try to implement a [TreeListView](http://www.google.com.au/search?q=treelistview&num=100&hl=en&prmd=ivns&tbm=isch&tbo=u&source=univ&sa=X&ei=MP1JTuf6BYyHrAew4ZGEBw&ved=0CGMQsAQ&biw=1680&bih=914) like control. – fatty Aug 16 '11 at 05:19

1 Answers1

1

You could use TreeView with HierarchicalDataTemplate as follows (taken from Here):

 public class WebPage
{
    public string Href { get; set; }
    public string PageTitle { get; set; }
    public List<WebPage> LinksInPage { get; set; }
}

public class Root
{
    public string Title { get; set; }
    public string Url { get; set; }
    public List<WebPage> WebPages { get; set; }
}


    <HierarchicalDataTemplate DataType="{x:Type data:Root}"
                              ItemsSource="{Binding Path=WebPages}">
                <TextBlock Text="{Binding Title}"></TextBlock>
    </HierarchicalDataTemplate>

    <HierarchicalDataTemplate DataType="{x:Type data:WebPage}"
                              ItemsSource="{Binding Path=LinksInPage}">
                <TextBlock Text="{Binding PageTitle}"></TextBlock>
    </HierarchicalDataTemplate>
Amittai Shapira
  • 3,749
  • 1
  • 30
  • 54