Click here to Skip to main content
16,020,822 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: c# Spotify API not returning correctly. Pin
Pete O'Hanlon4-Jun-23 8:42
mvePete O'Hanlon4-Jun-23 8:42 
AnswerRe: c# Spotify API not returning correctly. Pin
jschell5-Jun-23 5:01
jschell5-Jun-23 5:01 
QuestionNeed help please regarding your awesome WPF MultiComboBox project :) Pin
Member 1160463425-May-23 5:21
Member 1160463425-May-23 5:21 
AnswerRe: Need help please regarding your awesome WPF MultiComboBox project :) Pin
jeron125-May-23 5:50
jeron125-May-23 5:50 
AnswerRe: Need help please regarding your awesome WPF MultiComboBox project :) Pin
Richard Deeming25-May-23 21:28
mveRichard Deeming25-May-23 21:28 
QuestionNavigationControl - Part 3 Pin
Kevin Marois14-May-23 8:01
professionalKevin Marois14-May-23 8:01 
So I am continuing to work on my Navigation Control[^]. See this[^] and this[^]. The code is in this repo[^].

Special thanks to Richard Deeming for all your help so far. I've learned alot from you.

If you look at the image of the control in the first link above, you 'll see 3 sections, with the 3rd still loading. The expanders can be openend either by the user, or by saving & restoring a bool. On the NavigationPane control there's a DP called IsPaneExpanded. This get called with from the user or by the restoring during load.

When the control is being initialized I store the value of the DP.
Fields
// Stores the value of the DP IsPaneExpanded during initialization. See
// comments in the DP IsPaneExpanded 
private bool _isPaneExpanded = false;

// Set to true after the control has finished initializing
private bool _isInitialized = false;
IsPaneExpanded DP
public static readonly DependencyProperty IsPaneExpandedProperty =
            DependencyProperty.Register("IsPaneExpanded",
            typeof(bool),
            typeof(NavigationPane),
            new PropertyMetadata(false, new PropertyChangedCallback(OnIsPaneExpandedChanged)));

public bool IsPaneExpanded
{
    get { return (bool)GetValue(IsPaneExpandedProperty); }
    set { SetValue(IsPaneExpandedProperty, value); }
}

private static async void OnIsPaneExpandedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
    var control = (NavigationPane)d;

    if (!control._isInitialized)
    {
        // If here, the control is still being initialized. Store the
        // IsPaneExpanded setting for later use when the control's init
        // has finished
        control._isPaneExpanded = control.IsPaneExpanded;

        // Since the control is not loaded, there is nothing to show. But
        // since the IsExpanded can be set from the Window, and it's bound,
        // it's possible for the expander arrow to show open even though
        // there's nothing there. So force the expander to show as collapsed
        control.IsPaneExpanded = false;
    }
    else
    {
        // If here, the control has already been initialized, so go ahead
        // and call load. If here, the user clicked the expander arrow.
        if (control.IsPaneExpanded)
        {
            await control.Load();
        }
    }
}

Then, once initialzation is complete, I check that to see if the control's expander should be expanded.

Problem 1
The problem above is that the _isPaneExpanded is always false by the time it gets here. It IS being set to True in the DP, yet once the code reaches this point, it's false, so the load never happens. Maybe it's because the DP is static and the field isn't?

Problem 2
Another issue I see - I'd like the expander to open visuall FIRST, then call load. The Expander's Expanded event fires AFTER it has opened, but BEFORE the user sees anything visually the load is firing. Nothing changes visually until AFTER the load is complete.
private async void NavigationPane_Initialized(object? sender, EventArgs e)
{
    // If the control's IsPaneExpanded was set from the parent, then
    // the IsPandedExpanded DP would have set _isPaneExpanded = true.
    if (_isPaneExpanded) <==================================================== PROBLEM 1 HERE
    {
        // Now that the control has finished initializing, go ahead
        // and call load

        <=============================== PROBLEM 2 HERE. HOW DO YOU FORCE THE EXPANDER TO SHOW AS OPEN BEFORE LOAD
        await Load();
    }

    _isInitialized = true;
}
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.


modified 14-May-23 16:37pm.

AnswerRe: NavigationControl - Part 3 Pin
Richard Deeming14-May-23 21:40
mveRichard Deeming14-May-23 21:40 
GeneralRe: NavigationControl - Part 3 Pin
Kevin Marois15-May-23 17:14
professionalKevin Marois15-May-23 17:14 
QuestionBubbling Event Question Pin
Kevin Marois9-May-23 14:32
professionalKevin Marois9-May-23 14:32 
AnswerRe: Bubbling Event Question Pin
Gerry Schmitz12-May-23 5:28
mveGerry Schmitz12-May-23 5:28 
GeneralRe: Bubbling Event Question Pin
Kevin Marois12-May-23 5:35
professionalKevin Marois12-May-23 5:35 
GeneralRe: Bubbling Event Question Pin
Gerry Schmitz12-May-23 5:46
mveGerry Schmitz12-May-23 5:46 
GeneralRe: Bubbling Event Question Pin
Kevin Marois12-May-23 6:16
professionalKevin Marois12-May-23 6:16 
AnswerRe: Bubbling Event Question Pin
Kenneth Haugland14-May-23 9:55
mvaKenneth Haugland14-May-23 9:55 
GeneralRe: Bubbling Event Question Pin
Kevin Marois14-May-23 10:40
professionalKevin Marois14-May-23 10:40 
GeneralRe: Bubbling Event Question Pin
Kenneth Haugland14-May-23 11:06
mvaKenneth Haugland14-May-23 11:06 
GeneralRe: Bubbling Event Question Pin
Kevin Marois14-May-23 11:08
professionalKevin Marois14-May-23 11:08 
GeneralRe: Bubbling Event Question Pin
Kenneth Haugland14-May-23 11:19
mvaKenneth Haugland14-May-23 11:19 
GeneralRe: Bubbling Event Question Pin
Kevin Marois15-May-23 17:47
professionalKevin Marois15-May-23 17:47 
GeneralRe: Bubbling Event Question Pin
Kenneth Haugland15-May-23 18:46
mvaKenneth Haugland15-May-23 18:46 
GeneralRe: Bubbling Event Question Pin
Kevin Marois16-May-23 7:02
professionalKevin Marois16-May-23 7:02 
QuestionExpander Header Content Stretch Pin
Kevin Marois9-May-23 11:25
professionalKevin Marois9-May-23 11:25 
AnswerRe: Expander Header Content Stretch Pin
Richard Deeming9-May-23 21:48
mveRichard Deeming9-May-23 21:48 
GeneralRe: Expander Header Content Stretch Pin
Kevin Marois13-May-23 6:05
professionalKevin Marois13-May-23 6:05 
QuestionVB.NET WPF drag and drop for LISTBOX and TREEVIEWs..Anyone help with examples? Pin
Member 84579549-May-23 8:51
Member 84579549-May-23 8:51 

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.