Click here to Skip to main content
15,867,991 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Flat Button Style Problem Pin
Kevin Marois23-Apr-23 9:15
professionalKevin Marois23-Apr-23 9:15 
GeneralRe: Flat Button Style Problem Pin
Gerry Schmitz23-Apr-23 15:28
mveGerry Schmitz23-Apr-23 15:28 
GeneralRe: Flat Button Style Problem Pin
Kevin Marois25-Apr-23 19:08
professionalKevin Marois25-Apr-23 19:08 
GeneralRe: Flat Button Style Problem Pin
Gerry Schmitz26-Apr-23 5:20
mveGerry Schmitz26-Apr-23 5:20 
QuestionReport Designer Suggestions Pin
Kevin Marois13-Apr-23 13:37
professionalKevin Marois13-Apr-23 13:37 
AnswerRe: Report Designer Suggestions Pin
Pete O'Hanlon13-Apr-23 21:23
subeditorPete O'Hanlon13-Apr-23 21:23 
AnswerRe: Report Designer Suggestions Pin
Gerry Schmitz14-Apr-23 3:51
mveGerry Schmitz14-Apr-23 3:51 
QuestionCustom Navigation Control Pin
Kevin Marois12-Apr-23 16:23
professionalKevin Marois12-Apr-23 16:23 
Using WPF .Core 6

I am trying to create this custom control[^]. I'm open to a better way if anyone has one.

There is the outer Navigation Container, with Navigation Panes inside it. There can be any number of Navigation Panes. Each Navigation Pane will contain Navigation Items as links that the user can click on.

What I would like to happen when the Window shows is for the container to be there, and all the panes added and showing a spinning indicator that is visible as long as the pane is loading. Each pane must load independant of the other, and each could take any amount of time to load.

So far, the Navigation Container displays, and each NavigationPane shows, and the code begind for the Navigation Pane is receiving its data, but nothing shows up. And, the Spinning Indicator never goes away. The problem seems to be in the NavigationPane. The NavigationContainer is working as expected

Here's what I'm getting right now.[^]

I'm NOT getting any binding errors, and all relevant code is being hit - I just don't see anything.

Here's the NavigationContainer's Load() method. It adds each pane first, then retrieves the data for each. This all runs, and the data is assigned to the Items DP on the NavigationPane
private async Task Load()
        {
            if (NavigationPanes != null)
            {
                // Add a pane to the collection for each NavigationItemModel. This shows the panes
                // to the user BEFORE starting the data download
                foreach (var navigationPaneModel in NavigationPanes)
                {
                    var pane = new NavigationPane
                    {
                        Header = navigationPaneModel.Header ?? "",
                        NavigationItemType = navigationPaneModel.NavigationItemType
                    };
                    ContainerItems.Add(pane);
                }

                if (_apiProxy != null)
                {
                    // Go through each pane model
                    foreach (var navigationPaneModel in NavigationPanes)
                    {
                        await Task.Run(() =>
                        {
                            // Go the the back end & get the data
                            return _apiProxy.GetNavigationItems(navigationPaneModel.NavigationItemType);

                        }).ContinueWith(task =>
                        {
                            App.Current.Dispatcher.BeginInvoke(() =>
                            {
                                // Find the container for the data
                                var container = ContainerItems.FirstOrDefault(x => x.NavigationItemType == navigationPaneModel.NavigationItemType);
                                if (container != null && task.Result != null)
                                {
                                    // Assign the data to it
                                    container.Items = new ObservableCollection<NavigationEntity>(task.Result);
                                }
                            });
                        });

                    }
                }
            }

Here's the NavigationPane control from the Generic.xaml file
<Style TargetType="{x:Type ctrls:NavigationPane}">

    <Setter Property="Template">

        <Setter.Value>

            <ControlTemplate>

                <Grid>

                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>

                    <Expander Header="{Binding Header, RelativeSource={RelativeSource TemplatedParent}}"
                                IsExpanded="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}"
                                Padding="{Binding Padding, RelativeSource={RelativeSource TemplatedParent}}"
                                Margin="{Binding Margin, RelativeSource={RelativeSource TemplatedParent}}"
                                BorderBrush="{Binding BorderBrush, RelativeSource={RelativeSource TemplatedParent}}"
                                BorderThickness="{Binding BorderThickness, RelativeSource={RelativeSource TemplatedParent}}"
                                ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                ScrollViewer.VerticalScrollBarVisibility="Auto">

                        <Grid>

                            <ListBox ItemsSource="{Binding Items, RelativeSource={RelativeSource TemplatedParent}}"
                                        ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                        ScrollViewer.VerticalScrollBarVisibility="Auto"
                                        Margin="2"
                                        BorderBrush="Transparent"
                                        BorderThickness="0">

                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <mctrls:MaroisHyperlink x:Name="link" 
                                                                LinkText="{Binding Caption}"
                                                                HorizontalAlignment="Left"
                                                                Margin="2">

                                            <i:Interaction.Triggers>
                                                <i:EventTrigger EventName="LinkClicked">
                                                    <i:InvokeCommandAction Command="{Binding ItemLinkClickedCommand,
                                                                            RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type ctrls:NavigationPane}}}"
                                                                            CommandParameter="{Binding}"/>
                                                </i:EventTrigger>
                                            </i:Interaction.Triggers>

                                        </mctrls:MaroisHyperlink>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>

                            </ListBox>

                            <mctrls:MaroisSpinningProgress HorizontalAlignment="Center" 
                                                            VerticalAlignment="Center"
                                                            BorderThickness="1"
                                                            Margin="5,5,5,5"
                                                            Visibility="{Binding IsBusyVisible, RelativeSource={RelativeSource TemplatedParent}}"/>

                        </Grid>

                    </Expander>

                </Grid>

            </ControlTemplate>

        </Setter.Value>

    </Setter>

</Style>
Here's the NavigationPane.cs
public class NavigationPane : _ControlBase
{
    #region Properties
    public NavigationItemType NavigationItemType { get; set; }

    private Visibility _IsBusyVisible = Visibility.Visible;
    public Visibility IsBusyVisible
    {
        get { return _IsBusyVisible; }
        set
        {
            if (_IsBusyVisible != value)
            {
                _IsBusyVisible = value;
                RaisePropertyChanged(nameof(IsBusyVisible));
            }
        }
    }
    #endregion

    #region DP's
    public static readonly DependencyProperty HeaderProperty =
                DependencyProperty.Register("Header",
                typeof(string),
                typeof(NavigationPane),
                new PropertyMetadata(""));

    public string Header
    {
        get { return (string)GetValue(HeaderProperty); }
        set { SetValue(HeaderProperty, value); }
    }
    #endregion

    public static readonly DependencyProperty ItemsProperty =
                DependencyProperty.Register("Items",
                typeof(ObservableCollection<NavigationEntity>),
                typeof(NavigationPane),
                new PropertyMetadata(null, new PropertyChangedCallback(OnItemsChanged)));

    public ObservableCollection<NavigationEntity> Items
    {
        get { return (ObservableCollection<NavigationEntity>)GetValue(ItemsProperty); }
        set { SetValue(ItemsProperty, value); }
    }

    private static void OnItemsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        var control = (NavigationPane)d;
        control.IsBusyVisible = Visibility.Collapsed;  //<==== THIS IS BEING HIT, BUT THE INDICATOR STILL SHOWS. AND NO DATA ITEMS APPEAR
    }
    #endregion

    #region CTOR
    public NavigationPane()
    {
    }
    static NavigationPane()
    {
        DefaultStyleKeyProperty.OverrideMetadata(typeof(NavigationPane),
            new FrameworkPropertyMetadata(typeof(NavigationPane)));
    }
    #endregion

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

AnswerRe: Custom Navigation Control Pin
Pete O'Hanlon13-Apr-23 21:36
subeditorPete O'Hanlon13-Apr-23 21:36 
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
subeditorPete 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
subeditorPete 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
subeditorPete O'Hanlon23-Apr-23 21:09 
GeneralRe: Custom Navigation Control Pin
Richard Deeming23-Apr-23 23:07
mveRichard Deeming23-Apr-23 23:07 
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 

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.