Click here to Skip to main content
15,877,967 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: VB.NET WPF drag and drop for LISTBOX and TREEVIEWs..Anyone help with examples? Pin
Richard MacCutchan9-May-23 10:14
mveRichard MacCutchan9-May-23 10:14 
AnswerRe: VB.NET WPF drag and drop for LISTBOX and TREEVIEWs..Anyone help with examples? Pin
Richard Deeming9-May-23 21:38
mveRichard Deeming9-May-23 21:38 
QuestionListBoxItem DataTemplate with HyperLink Problem Pin
Kevin Marois8-May-23 11:52
professionalKevin Marois8-May-23 11:52 
AnswerRe: ListBoxItem DataTemplate with HyperLink Problem Pin
Richard Deeming8-May-23 21:44
mveRichard Deeming8-May-23 21:44 
GeneralRe: ListBoxItem DataTemplate with HyperLink Problem Pin
Kevin Marois9-May-23 5:29
professionalKevin Marois9-May-23 5:29 
QuestionCustomControl Styling Question Pin
Kevin Marois4-May-23 17:22
professionalKevin Marois4-May-23 17:22 
AnswerRe: CustomControl Styling Question Pin
Pete O'Hanlon4-May-23 20:29
mvePete O'Hanlon4-May-23 20:29 
QuestionNavigationControl - Continued Pin
Kevin Marois2-May-23 14:49
professionalKevin Marois2-May-23 14:49 
I am working on this Navigation control[^].

See this earlier post[^] The code is in this repository[^].

What I'm trying to accomplish now is to have each Pane load individually only when expanded.

I added a Func that I want to use inside the pane to call the data
<pre>NavigationPaneInfos = new List<NavigationPaneModel>
{
    new NavigationPaneModel
    {
        Header = "Projects", 
        NavigationItemType = NavigationItemType.Project, 
        IsExpanded = true,
        DataSource = Repository.GetNavigationItems // <=== FUNC
    },

    new NavigationPaneModel
    {
        Header = "Inventory", 
        NavigationItemType = NavigationItemType.Inventory,
        DataSource = Repository.GetNavigationItems
    },

    new NavigationPaneModel
    {
        Header = "Companies" , 
        NavigationItemType = NavigationItemType.Company,
        DataSource = Repository.GetNavigationItems
    },

    new NavigationPaneModel
    {
        Header = "Employees", 
        NavigationItemType = NavigationItemType.Employee,
        DataSource = Repository.GetNavigationItems
    }
};

Next I modified the outer container's loading
private void Load()
{
    if (NavigationPanes != null)
    {
        ContainerItems = new List<NavigationPane>();

        foreach (var navigationPaneModel in NavigationPanes)
        {
            var navigationPane = new NavigationPane
            { 
                Header = navigationPaneModel.Header ?? "",
                ItemType = navigationPaneModel.NavigationItemType,
                NavigationPaneModel = navigationPaneModel

            };
            ContainerItems.Add(navigationPane);

            navigationPane.IsExpanded = navigationPaneModel.IsExpanded; //<====Triggers loading the pane. Will be set at runtime later
        }
    }
}
Finally, I changed the pane loading to only happen when IsExpanded is changed:
public static readonly DependencyProperty IsExpandedProperty =
            DependencyProperty.Register("IsExpanded",
            typeof(bool),
            typeof(NavigationPane),
            new PropertyMetadata(false, new PropertyChangedCallback(OnIsExpandedChanged)));

public bool IsExpanded
{
    get { return (bool)GetValue(IsExpandedProperty); }
    set { SetValue(IsExpandedProperty, value); }
}

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

    if (control.NavigationPaneModel != null)
    {
        await control.Load();
    }
}
private async Task Load()
{
    if (NavigationPaneModel != null && NavigationPaneModel.DataSource != null)
    {
        var dataSource = NavigationPaneModel.DataSource(NavigationPaneModel.NavigationItemType);

        List<NavigationEntity>? data = null;

        if (dataSource != null)
        {
            data = await Task.Run(() => dataSource);
        }

        if (data != null)
        {
            Items = new ObservableCollection<NavigationEntity>(data);
        }
    }
}


It's throwing a binding error when I invoke the func.
A 'Binding' cannot be set on the 'Header' property of type 'NavigationPane'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject.'
Yet the Header property IS a DP.

I've been staring it this for hours. I would appreciate some help. Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.

AnswerRe: NavigationControl - Continued Pin
Richard Deeming2-May-23 22:19
mveRichard Deeming2-May-23 22:19 
GeneralRe: NavigationControl - Continued Pin
Kevin Marois3-May-23 5:21
professionalKevin Marois3-May-23 5:21 
GeneralRe: NavigationControl - Continued Pin
Kevin Marois3-May-23 15:10
professionalKevin Marois3-May-23 15:10 
GeneralRe: NavigationControl - Continued Pin
Richard Deeming3-May-23 21:35
mveRichard Deeming3-May-23 21:35 
QuestionWPF 3D rendering Pin
Kenneth Haugland1-May-23 4:52
mvaKenneth Haugland1-May-23 4:52 
AnswerRe: WPF 3D rendering Pin
Gerry Schmitz2-May-23 6:14
mveGerry Schmitz2-May-23 6:14 
GeneralRe: WPF 3D rendering Pin
Kenneth Haugland2-May-23 9:59
mvaKenneth Haugland2-May-23 9:59 
AnswerRe: WPF 3D rendering Pin
RedDk2-May-23 8:03
RedDk2-May-23 8:03 
GeneralRe: WPF 3D rendering Pin
Kenneth Haugland2-May-23 10:01
mvaKenneth Haugland2-May-23 10:01 
QuestionExpander in ListBoxItem Width Problem Pin
Kevin Marois27-Apr-23 7:19
professionalKevin Marois27-Apr-23 7:19 
AnswerRe: Expander in ListBoxItem Width Problem Pin
Richard Deeming1-May-23 23:09
mveRichard Deeming1-May-23 23:09 
GeneralRe: Expander in ListBoxItem Width Problem Pin
Kevin Marois2-May-23 7:12
professionalKevin Marois2-May-23 7:12 
QuestionSpinning Indicator Control Error Pin
Kevin Marois26-Apr-23 14:32
professionalKevin Marois26-Apr-23 14:32 
AnswerRe: Spinning Indicator Control Error Pin
Gerry Schmitz27-Apr-23 7:01
mveGerry Schmitz27-Apr-23 7:01 
GeneralRe: Spinning Indicator Control Error Pin
Kevin Marois27-Apr-23 7:27
professionalKevin Marois27-Apr-23 7:27 
GeneralRe: Spinning Indicator Control Error Pin
Gerry Schmitz28-Apr-23 4:46
mveGerry Schmitz28-Apr-23 4:46 
GeneralRe: Spinning Indicator Control Error Pin
Kevin Marois28-Apr-23 7:24
professionalKevin Marois28-Apr-23 7:24 

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.