Click here to Skip to main content
14,302,860 members

Silverlight / WPF

 
GeneralRe: Iterating the cells of a gridview Pin
Gerry Schmitz6-Dec-17 16:53
mveGerry Schmitz6-Dec-17 16:53 
GeneralRe: Iterating the cells of a gridview Pin
Member 83993636-Dec-17 17:14
memberMember 83993636-Dec-17 17:14 
GeneralRe: Iterating the cells of a gridview Pin
Gerry Schmitz6-Dec-17 17:52
mveGerry Schmitz6-Dec-17 17:52 
GeneralRe: Iterating the cells of a gridview Pin
Member 83993636-Dec-17 18:01
memberMember 83993636-Dec-17 18:01 
GeneralRe: Iterating the cells of a gridview Pin
Gerry Schmitz6-Dec-17 18:13
mveGerry Schmitz6-Dec-17 18:13 
QuestionHow To Create This UI Pin
Kevin Marois1-Dec-17 5:17
professionalKevin Marois1-Dec-17 5:17 
AnswerRe: How To Create This UI Pin
Mycroft Holmes2-Dec-17 12:38
memberMycroft Holmes2-Dec-17 12:38 
QuestionWPF TreeView - Some Nodes Not Showing Pin
Kevin Marois30-Nov-17 11:56
professionalKevin Marois30-Nov-17 11:56 
I have a WPF TreeView that I'm trying to load with the following items:
Projects
  - Builder 1
    - Project 1a
    - Project 1b
  - Builder 2
    - Project 2a
    - Project 2b

Companies
  - Company 1
  - Company 2

Employees
  - Employee 1
  - Employee 2

Problem
The Companies and Employees nodes both load fine. For the first level all I see is "Projects". The Builders and Projects under them don't appear. I'm guessing my HierarchicalDataTemplate is wrong but I can't see it. Anyone see what's wrong?

Thanks

Models
public class NavigationCategory : BindableBase // (Implements INPC - Abbreviated here)
{
    public string Caption { get; set; }
    public NavigationGroup Group { get; set; }
    public ObservableCollection<NavigationCategory> Categories { get; set; }
    public ObservableCollection<NavigationItem> NavigationItems { get; set; }
}

public class NavigationItem : BindableBase
{
    public int ItemId { get; set; }
    public string Caption { get; set; }
    public ViewType ViewType { get; set; }
}
The XAML
<TreeView Name="Navigation" 
            Grid.Row="1" 
            Grid.Column="0" 
            ItemsSource="{Binding NavigationBarItems}">

    <TreeView.Resources>

        <HierarchicalDataTemplate DataType="{x:Type models:NavigationCategory}" 
                                    ItemsSource="{Binding NavigationItems}">
            <TextBlock Text="{Binding Path=Caption}" />
        </HierarchicalDataTemplate>

        <DataTemplate DataType="{x:Type models:NavigationItem}">
            <TextBlock Text="{Binding Path=Caption}" />
        </DataTemplate>

    </TreeView.Resources>

</TreeView>
View Model
private ObservableCollection<NavigationCategory> _NavigationBarItems;
public ObservableCollection<NavigationCategory> NavigationBarItems
{
    get { return _NavigationBarItems; }
    set
    {
        if (_NavigationBarItems != value)
        {
            _NavigationBarItems = value;
            RaisePropertyChanged("NavigationBarItems");
        }
    }
}

private void LoadNavBar()
{
    NavigationBarItems = new ObservableCollection<NavigationCategory>
    {
        new NavigationCategory
        {
            Group = NavigationGroup.Projects,
            Caption = "Projects",

            Categories = new ObservableCollection<NavigationCategory>
            {
                new NavigationCategory
                {
                    Group = NavigationGroup.Builders,
                    Caption = "Builder 1",
                    NavigationItems = new ObservableCollection<NavigationItem>
                    {
                        new NavigationItem
                        {
                            ItemId = 101,
                            Caption = "Project 1a",
                            ViewType = ViewType.Project
                        },
                        new NavigationItem
                        {
                            ItemId = 102,
                            Caption = "Project 1b",
                            ViewType = ViewType.Project
                        }
                    }

                },
                new NavigationCategory
                {
                    Group = NavigationGroup.Builders,
                    Caption = "Builder 2",
                    NavigationItems = new ObservableCollection<NavigationItem>
                    {
                        new NavigationItem
                        {
                            ItemId = 201,
                            Caption = "Project 2a",
                            ViewType = ViewType.Project
                        },
                        new NavigationItem
                        {
                            ItemId = 202,
                            Caption = "Project 2b",
                            ViewType = ViewType.Project
                        }
                    }

                }
            }
        },

        new NavigationCategory
        {
            Group = NavigationGroup.Companies,
            Caption = "Companies",

            NavigationItems = new ObservableCollection<NavigationItem>
            {
                new NavigationItem
                {
                    ItemId = 301,
                    Caption = "Company 1a",
                    ViewType = ViewType.Company
                },
                new NavigationItem
                {
                    ItemId = 302,
                    Caption = "Company 1b",
                    ViewType = ViewType.Company
                }
            }
        },

        new NavigationCategory
        {
            Group = NavigationGroup.Employees,
            Caption = "Employees",

            NavigationItems = new ObservableCollection<NavigationItem>
            {
                new NavigationItem
                {
                    ItemId = 401,
                    Caption = "Employee 1a",
                    ViewType = ViewType.Employee
                }
            }
        }
    };
}
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.

AnswerRe: WPF TreeView - Some Nodes Not Showing Pin
Mycroft Holmes30-Nov-17 12:14
memberMycroft Holmes30-Nov-17 12:14 
GeneralRe: WPF TreeView - Some Nodes Not Showing Pin
Kevin Marois30-Nov-17 12:15
professionalKevin Marois30-Nov-17 12:15 
GeneralRe: WPF TreeView - Some Nodes Not Showing Pin
Mycroft Holmes30-Nov-17 12:41
memberMycroft Holmes30-Nov-17 12:41 
GeneralRe: WPF TreeView - Some Nodes Not Showing Pin
Kevin Marois30-Nov-17 12:43
professionalKevin Marois30-Nov-17 12:43 
GeneralRe: WPF TreeView - Some Nodes Not Showing Pin
Mycroft Holmes30-Nov-17 19:41
memberMycroft Holmes30-Nov-17 19:41 
GeneralRe: WPF TreeView - Some Nodes Not Showing Pin
Kevin Marois30-Nov-17 13:00
professionalKevin Marois30-Nov-17 13:00 
GeneralRe: WPF TreeView - Some Nodes Not Showing Pin
Kevin Marois30-Nov-17 12:38
professionalKevin Marois30-Nov-17 12:38 
QuestionMahApps Pin
Kevin Marois14-Nov-17 7:54
professionalKevin Marois14-Nov-17 7:54 
AnswerRe: MahApps Pin
Pete O'Hanlon14-Nov-17 10:32
protectorPete O'Hanlon14-Nov-17 10:32 
QuestionMEF ImportingConstructor - How do we pass different concrete class if accepting parameter is interface type Pin
Ashfaque Hussain6-Nov-17 2:40
memberAshfaque Hussain6-Nov-17 2:40 
AnswerRe: MEF ImportingConstructor - How do we pass different concrete class if accepting parameter is interface type Pin
Richard Deeming6-Nov-17 3:20
mveRichard Deeming6-Nov-17 3:20 
QuestionWPF, DevExpress: Stop dxn:NavBarControl recreates it's children Pin
Member 1347601722-Oct-17 21:18
memberMember 1347601722-Oct-17 21:18 
AnswerRe: WPF, DevExpress: Stop dxn:NavBarControl recreates it's children Pin
Gerry Schmitz23-Oct-17 19:13
mveGerry Schmitz23-Oct-17 19:13 
GeneralRe: WPF, DevExpress: Stop dxn:NavBarControl recreates it's children Pin
Antoon Verroken26-Oct-17 1:26
memberAntoon Verroken26-Oct-17 1:26 
GeneralRe: WPF, DevExpress: Stop dxn:NavBarControl recreates it's children Pin
Gerry Schmitz26-Oct-17 4:09
mveGerry Schmitz26-Oct-17 4:09 
GeneralRe: WPF, DevExpress: Stop dxn:NavBarControl recreates it's children Pin
Antoon Verroken26-Oct-17 7:24
memberAntoon Verroken26-Oct-17 7:24 
GeneralRe: WPF, DevExpress: Stop dxn:NavBarControl recreates it's children Pin
Gerry Schmitz26-Oct-17 8:03
mveGerry Schmitz26-Oct-17 8:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.