TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
grounder
NA
3
3.2k
WPF TreeView + LINQ problem
May 7 2012 6:55 AM
Hello,
some days ago I have found a problem while trying to make TreeView in my WPF + LINQ application. In my database I have an table PC_ProductCategories, which looks like this:
PC_ID - primary key
PC_NAME - name of category
PC_PC_ID - foregin key, which direct to the same table.
By foregin key PC_PC_ID I make child/parent structure, so every category have in PC_PC_ID it's parent's ID.
In my XAML it looks like this:
<
TreeView
ItemsSource
="{
Binding
Path
=
ProductCategoriesToShow
}
"
...
>
<
TreeView.ItemTemplate
>
<
HierarchicalDataTemplate
ItemsSource
="{
Binding
Path
=
PC_ProductCategories
}
"
>
<
TextBlock
Text
="{
Binding
Path
=
PC_NAME
}
"
/>
</
HierarchicalDataTemplate
>
</
TreeView.ItemTemplate
>
</
TreeView
>
TreeView take it almost okey - the categories which have children are possible to "open" and I can see their children,
but the problem is - on the "ground" "0" level (just as everything is closed), the TreeView shows all the categories (so the children are doubled, because they're the "0" level, and on their good levels of treeview). Is it still problem of my xaml or binding, or I really need to make next class by hand to just keep something like "String Name; IList<category> listOfChildren"?
Reply
Answers (
1
)
Upload control with TextBox and Button.
Regular Expression