Click here to Skip to main content
15,880,469 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Custom Navigation Control Pin
Richard Deeming13-Apr-23 22:47
mveRichard Deeming13-Apr-23 22:47 
GeneralRe: Custom Navigation Control Pin
Kevin Marois15-Apr-23 10:22
professionalKevin Marois15-Apr-23 10:22 
GeneralRe: Custom Navigation Control Pin
Pete O'Hanlon16-Apr-23 21:54
mvePete O'Hanlon16-Apr-23 21:54 
GeneralRe: Custom Navigation Control Pin
Kevin Marois17-Apr-23 5:10
professionalKevin Marois17-Apr-23 5:10 
GeneralRe: Custom Navigation Control Pin
Pete O'Hanlon17-Apr-23 10:52
mvePete O'Hanlon17-Apr-23 10:52 
GeneralRe: Custom Navigation Control Pin
Kevin Marois22-Apr-23 17:54
professionalKevin Marois22-Apr-23 17:54 
GeneralRe: Custom Navigation Control Pin
Pete O'Hanlon23-Apr-23 21:09
mvePete O'Hanlon23-Apr-23 21:09 
GeneralRe: Custom Navigation Control Pin
Richard Deeming23-Apr-23 23:07
mveRichard Deeming23-Apr-23 23:07 
The first obvious issue: the ContainerItems property is not a dependency property. As I said, for a DependencyObject-derived class, WPF will only observe property changes for dependency properties.
C#
public static readonly DependencyProperty ContainerItemsProperty
    = DependencyProperty.Register("ContainerItems",
        typeof(List<NavigationPane>),
        typeof(NavigationContainer),
        new PropertyMetadata(null));

public List<NavigationPane> ContainerItems
{
    get { return (List<NavigationPane>)GetValue(ContainerItemsProperty); }
    set { SetValue(ContainerItemsProperty, value); }
}

Next problem: since you're using a List<T> rather than an ObservableCollection<T>, WPF will only notice when you set the property. Since you do that before adding any items to the list, WPF will never notice the panes being loaded. Change the code to set the property after populating the list:
C#
private async Task Load()
{
    if (NavigationPanes != null)
    {
        var items = new List<NavigationPane>();

        List<Task> tasks = new List<Task>(NavigationPanes.Count);
        foreach (var navigationPaneModel in NavigationPanes)
        {
            tasks.Add(LoadPane(navigationPaneModel, items));
        }

        await Task.WhenAll(tasks);
		ContainerItems = items;
	}
}

private async Task LoadPane(NavigationPaneModel navigationPaneModel, List<NavigationPane> containerItems)

With those changes in place (and dropping the Thread.Sleep values so it loads in a reasonable time), I now get four expanders in the list. However, although they have different headers, none of them contain any data.

Looking in the Generic.xaml file, you're binding the Header property, but not the Items property:
XAML
<ctrls:NavigationPane BorderBrush="Yellow" 
    BorderThickness="1"
    Background="Red"
    HorizontalAlignment="Stretch"
    Header="{Binding Header}"
    Margin="0,0,0,1"/>
Once you add Items="{Binding Items}" to that, the listboxes are now populated.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

GeneralRe: Custom Navigation Control Pin
Kevin Marois25-Apr-23 19:02
professionalKevin Marois25-Apr-23 19:02 
GeneralRe: Custom Navigation Control Pin
Kevin Marois27-Apr-23 7:21
professionalKevin Marois27-Apr-23 7:21 
QuestionPath in Style Question Pin
Kevin Marois10-Apr-23 13:43
professionalKevin Marois10-Apr-23 13:43 
AnswerRe: Path in Style Question Pin
Gerry Schmitz12-Apr-23 6:18
mveGerry Schmitz12-Apr-23 6:18 
GeneralRe: Path in Style Question Pin
Kevin Marois12-Apr-23 6:33
professionalKevin Marois12-Apr-23 6:33 
GeneralRe: Path in Style Question Pin
Gerry Schmitz12-Apr-23 7:01
mveGerry Schmitz12-Apr-23 7:01 
GeneralRe: Path in Style Question Pin
Kevin Marois12-Apr-23 7:06
professionalKevin Marois12-Apr-23 7:06 
GeneralRe: Path in Style Question Pin
Kevin Marois18-Apr-23 14:45
professionalKevin Marois18-Apr-23 14:45 
QuestionDraw Images Pin
Kevin Marois4-Apr-23 14:24
professionalKevin Marois4-Apr-23 14:24 
AnswerRe: Draw Images Pin
Andy_L_J5-Apr-23 1:41
Andy_L_J5-Apr-23 1:41 
AnswerRe: Draw Images Pin
Pete O'Hanlon5-Apr-23 2:27
mvePete O'Hanlon5-Apr-23 2:27 
GeneralRe: Draw Images Pin
Kevin Marois7-Apr-23 6:31
professionalKevin Marois7-Apr-23 6:31 
GeneralRe: Draw Images Pin
Pete O'Hanlon13-Apr-23 21:41
mvePete O'Hanlon13-Apr-23 21:41 
QuestionJson Based Themes Pin
Kevin Marois6-Mar-23 6:39
professionalKevin Marois6-Mar-23 6:39 
QuestionDropDown TreeView Pin
Kevin Marois22-Feb-23 18:34
professionalKevin Marois22-Feb-23 18:34 
AnswerRe: DropDown TreeView Pin
Gerry Schmitz24-Feb-23 9:08
mveGerry Schmitz24-Feb-23 9:08 
GeneralRe: DropDown TreeView Pin
Kevin Marois2-Mar-23 11:30
professionalKevin Marois2-Mar-23 11:30 

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.