|
You abstract "... new DiffuseMaterial(), etc." to a separate WPF project; get it working there; then import it back.
(Someone was dealing with "DiffuseMaterial" and 3rd party software in Q&A and not getting anywhere either).
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
I figured it out anyways.
|
|
|
|
|
|
|
I'm working on this control[^]. The code is in this repository[^].
It has a listbox filled with expanders. I can't seem to get the expanders to size horizontally corrrectly. The expanders should horizontally fill inside the listboxitem.
This is what I'm gettting[^]
I tried binding the width of the expander to the width of the listboxitem, but it gives some strange results.
See this[^]
I found some Google hits that say to set the width of the expanders header content. Here's one example[^]. I've tried this and it has the same affect as in my second picture.
And, even more strange, when I do try to bind the width, the vertical scrollbar on the right is visible and enabled, but no longer drags to scroll. Mouse wheel scrolling is unafffected
Anyone know the right way to do this?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Remove the Width binding and the HorizontalAlignment on the ctrls:NavigationPane element. Instead, set the HorizontalContentAlignment property on the ListBox .
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:ctrls="clr-namespace:NavigationContainer">
<Style TargetType="{x:Type ctrls:NavigationPane}">
<Setter Property="MaxHeight" Value="300"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ctrls:NavigationPane}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Expander Header="{Binding Header, 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"
IsExpanded="True">
<Grid>
<ListBox ItemsSource="{Binding Items, RelativeSource={RelativeSource TemplatedParent}}"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto"
Margin="2"
BorderBrush="Transparent"
BorderThickness="0">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Caption}"
Margin="2"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Expander>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type ctrls:NavigationContainer}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ctrls:NavigationContainer}">
<Border Padding="{Binding Padding, RelativeSource={RelativeSource TemplatedParent}}"
Margin="{Binding Margin, RelativeSource={RelativeSource TemplatedParent}}"
Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}"
BorderBrush="{Binding BorderBrush, RelativeSource={RelativeSource TemplatedParent}}"
BorderThickness="{Binding BorderThickness, RelativeSource={RelativeSource TemplatedParent}}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ListBox Grid.Row="1"
Margin="1"
BorderThickness="1"
HorizontalContentAlignment="Stretch"
ItemsSource="{Binding ContainerItems, RelativeSource={RelativeSource TemplatedParent}}"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto">
<ListBox.ItemTemplate>
<DataTemplate>
<ctrls:NavigationPane
BorderBrush="Orange"
BorderThickness="3"
Background="Red"
Header="{Binding Header}"
Items="{Binding Items}"
Margin="0,0,0,1"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary> xaml - How to get a ListBox ItemTemplate to stretch horizontally the full width of the ListBox? - Stack Overflow[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
That did it.
I spent hours trying to figure that out. It seems in this case all the properties have to be just right.
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
I have a spinning indicator custom control[^]. It's currently in a UserControl that works fine. But now I want to put it in a CustomControl instead.
It's throwing this exception. If I comment out the DoubleAnimation then it doesn't throw, but it also doesn't show anything.
Cannot resolve all property references in the property path 'RenderTransform.Angle'. Verify that applicable objects support the properties.
Inner Exception 1:
InvalidOperationException: Cannot resolve all property references in the property path 'RenderTransform.Angle'. Verify that applicable objects support the properties.
I'm stumped on this. Anyone know what's wrong?
Code behind
It has properties for the Indicator Color, Indicator Text Color, and Message:
public class MaroisSpinningProgress : ControlBase
{
#region DP IndicatorColor
public static readonly DependencyProperty IndicatorColorProperty =
DependencyProperty.Register("IndicatorColor",
typeof(SolidColorBrush),
typeof(MaroisSpinningProgress),
new PropertyMetadata(new SolidColorBrush(Colors.Black), new PropertyChangedCallback(OnIndicatorColorChanged)));
public SolidColorBrush IndicatorColor
{
get { return (SolidColorBrush)GetValue(IndicatorColorProperty); }
set { SetValue(IndicatorColorProperty, value); }
}
private static void OnIndicatorColorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var control = (MaroisSpinningProgress)d;
}
#endregion
#region DP IndicatorTextColor
public static readonly DependencyProperty IndicatorTextColorProperty =
DependencyProperty.Register("IndicatorTextColor",
typeof(SolidColorBrush),
typeof(MaroisSpinningProgress),
new PropertyMetadata(new SolidColorBrush(Colors.Black)));
public SolidColorBrush IndicatorTextColor
{
get { return (SolidColorBrush)GetValue(IndicatorTextColorProperty); }
set { SetValue(IndicatorTextColorProperty, value); }
}
#endregion
#region DP Message
public static readonly DependencyProperty MessageProperty =
DependencyProperty.Register("Message",
typeof(string),
typeof(MaroisSpinningProgress),
new PropertyMetadata("", new PropertyChangedCallback(OnMessageChanged)));
public string Message
{
get { return (string)GetValue(MessageProperty); }
set { SetValue(MessageProperty, value); }
}
private static void OnMessageChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var control = (MaroisSpinningProgress)d;
}
#endregion
#region CTOR
public MaroisSpinningProgress()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(MaroisSpinningProgress),
new FrameworkPropertyMetadata(typeof(MaroisSpinningProgress)));
}
#endregion
}
XAML
<Style TargetType="{x:Type local:MaroisSpinningProgress}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:MaroisSpinningProgress}">
<Viewbox HorizontalAlignment="Center"
VerticalAlignment="Center">
<Grid Background="Transparent"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Canvas Name="Canvas1"<br />
RenderTransformOrigin="0.5,0.5"<br />
HorizontalAlignment="Center"<br />
VerticalAlignment="Center"
Width="120"
Height="120"
Margin="15">
<Canvas.RenderTransform>
<RotateTransform Angle="0" />
</Canvas.RenderTransform>
<Canvas.Style>
<Style TargetType="Canvas">
<Style.Triggers>
<Trigger Property="IsVisible" Value="True">
<Trigger.EnterActions>
<BeginStoryboard Name="Storyboard_Rotate">
<Storyboard RepeatBehavior="Forever">
<DoubleAnimation Storyboard.TargetProperty="RenderTransform.Angle"
From="0"
To="360"
Duration="0:0:3"/>
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<StopStoryboard BeginStoryboardName="Storyboard_Rotate" />
</Trigger.ExitActions>
</Trigger>
</Style.Triggers>
</Style>
</Canvas.Style>
<Ellipse Width="20" Height="20" Stretch="Fill" Fill="{Binding IndicatorColor, Mode=TwoWay}" Opacity="1.0" Canvas.Left="50" Canvas.Top="0" />
<Ellipse Width="20" Height="20" Stretch="Fill" Fill="{Binding IndicatorColor, Mode=TwoWay}" Opacity="0.9" Canvas.Left="20.6107373853764" Canvas.Top="9.54915028125262" />
<Ellipse Width="20" Height="20" Stretch="Fill" Fill="{Binding IndicatorColor, Mode=TwoWay}" Opacity="0.8" Canvas.Left="2.44717418524233" Canvas.Top="34.5491502812526" />
<Ellipse Width="20" Height="20" Stretch="Fill" Fill="{Binding IndicatorColor, Mode=TwoWay}" Opacity="0.7" Canvas.Left="2.44717418524232" Canvas.Top="65.4508497187474" />
<Ellipse Width="20" Height="20" Stretch="Fill" Fill="{Binding IndicatorColor, Mode=TwoWay}" Opacity="0.6" Canvas.Left="20.6107373853763" Canvas.Top="90.4508497187474" />
<Ellipse Width="20" Height="20" Stretch="Fill" Fill="{Binding IndicatorColor, Mode=TwoWay}" Opacity="0.5" Canvas.Left="50" Canvas.Top="100" />
<Ellipse Width="20" Height="20" Stretch="Fill" Fill="{Binding IndicatorColor, Mode=TwoWay}" Opacity="0.4" Canvas.Left="79.3892626146236" Canvas.Top="90.4508497187474" />
<Ellipse Width="20" Height="20" Stretch="Fill" Fill="{Binding IndicatorColor, Mode=TwoWay}" Opacity="0.3" Canvas.Left="97.5528258147577" Canvas.Top="65.4508497187474" />
<Ellipse Width="20" Height="20" Stretch="Fill" Fill="{Binding IndicatorColor, Mode=TwoWay}" Opacity="0.2" Canvas.Left="97.5528258147577" Canvas.Top="34.5491502812526" />
</Canvas>
<TextBlock Grid.Row="1"
Text="{Binding Message}"
FontSize="18"
Foreground="{Binding IndicatorTextColor}"
Visibility="{Binding IsShowingText}"/>
</Grid>
</Viewbox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
The "target" is the RotateTransform; the "target property" is "Angle".
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
I'm sorry, I don't think I understand. Isn't that what I have here
<Canvas.RenderTransform>
<RotateTransform Angle="0" />
</Canvas.RenderTransform>
and here
<DoubleAnimation Storyboard.TargetProperty="RenderTransform.Angle"
From="0"
To="360"
Duration="0:0:3"/>
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
You give the RotateTransform a "Name"; then reference it in "TargetName" of the StoryBoard. Where in "RenderTransform" (abstract Transform) is there an "Angle" property?
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
|
I'm trying to create a flat button style:
Style
<Style x:Key="buttonStyle"
TargetType="{x:Type Button}">
<Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Margin" Value="0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Height" Value="25"/>
<Setter Property="Width" Value="75"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="border"
Margin="2"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding BorderThickness}">
<ContentPresenter x:Name="contentPresenter"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
TextElement.Foreground="{TemplateBinding Foreground}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="border" Property="BorderBrush" Value="{StaticResource Button.Hover.Foreground}" />
<Setter TargetName="border" Property="BorderThickness" Value="1" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="border" Property="BorderBrush" Value="{StaticResource Button.Pressed.Foreground}" />
<Setter TargetName="border" Property="BorderThickness" Value="1" />
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="border" Property="BorderBrush" Value="{StaticResource Button.Disabled.Foreground}" />
<Setter TargetName="border" Property="BorderThickness" Value="0" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Usage
<Button Grid.Row="5"
Grid.Column="0"
IsDefault="True"
Content="Test"
Command="{Binding SignInCommand}"
Style="{DynamicResource buttonStyle}"
Background="LightSeaGreen"
Foreground="Red"
Margin="0,25,0,0"/>
The problem is that the foreground doesn't change. I know it's probably the ContentPresenter, but I don't know what to do about it. What's the right way to fix this?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Doesn't change from what to what? Is it "Red"?
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Sorry I wasn't clear.
I set it to red but it shows as black.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
|
Nope, didn't work.
I guess I could replace the ContentPresenter with a TextBlock, but then I'd need a DP behind it for the text.
There's gotta be a XAML way to do this
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
If content is a "string" (as in your case), the Button uses a TextBlock; if content is some UI element composite, a "ForeGround" color may make little sense. So, yes, I would have used a TextBlock (as "content") in the first place. (I sometimes use one or more FontIcons overlayed in a grid). (The "dynamic" resource binding also makes little sense in this case)
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
I'm using DevExpress reporting. I'm looking for alternatives.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Is there a reason you need an alternative? If there's a missing feature, that could help people with providing you with suggestions.
|
|
|
|
|
I use a "designer" almost never. You spend 90% of the time getting the last 10% to look / work right (if ever). Writing custom reports isn't that hard if that's what you did before "designers".
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
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)
{
foreach (var navigationPaneModel in NavigationPanes)
{
var pane = new NavigationPane
{
Header = navigationPaneModel.Header ?? "",
NavigationItemType = navigationPaneModel.NavigationItemType
};
ContainerItems.Add(pane);
}
if (_apiProxy != null)
{
foreach (var navigationPaneModel in NavigationPanes)
{
await Task.Run(() =>
{
return _apiProxy.GetNavigationItems(navigationPaneModel.NavigationItemType);
}).ContinueWith(task =>
{
App.Current.Dispatcher.BeginInvoke(() =>
{
var container = ContainerItems.FirstOrDefault(x => x.NavigationItemType == navigationPaneModel.NavigationItemType);
if (container != null && task.Result != null)
{
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;
}
#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.
|
|
|
|
|
My immediate thought is that the problem is in the task continuation. Have you checked the result of the FirstOrDefault, to make sure that it is actually finding the container?
|
|
|
|
|
Kevin Marois wrote: Each pane must load independant of the other
That doesn't seem to tally with:
Kevin Marois wrote:
foreach (var navigationPaneModel in NavigationPanes)
{
await Task.Run(() =>
{
return _apiProxy.GetNavigationItems(navigationPaneModel.NavigationItemType);
}).ContinueWith(task =>
{
App.Current.Dispatcher.BeginInvoke(() =>
{
var container = ContainerItems.FirstOrDefault(x => x.NavigationItemType == navigationPaneModel.NavigationItemType);
if (container != null && task.Result != null)
{
container.Items = new ObservableCollection<NavigationEntity>(task.Result);
}
});
});
} Your loop kicks off a task to load each pane, then waits for that task to complete before trying to load the next pane.
Try extracting the "load a pane" code to a separate method:
private async Task LoadPane(NavigationPane navigationPaneModel)
{
var result = await Task.Run(() => _apiProxy.GetNavigationItems(navigationPaneModel.NavigationItemType);
if (result is null) return;
var container = ContainerItems.FirstOrDefault(x => x.NavigationItemType == navigationPaneModel.NavigationItemType);
if (container is null) return;
container.Items = new ObservableCollection<NavigationEntity>(result);
} Then change the loop to:
List<Task> tasks = new List<Task>(NavigationPanes.Count);
foreach (var navigationPaneModel in NavigationPanes)
{
tasks.Add(LoadPane(navigationPaneModel));
}
await Task.WhenAll(tasks);
Kevin Marois wrote:
control.IsBusyVisible = Visibility.Collapsed; You've declared the IsBusyVisible property as a regular property, but your NavigationPane class is a DependencyObject . The WPF binding system will only observe changes to DependencyProperty properties on a DependencyObject -derived class. Change the property to a dependency property:
public static readonly DependencyProperty IsBusyVisibleProperty = DependencyProperty.Register(
"IsBusyVisible", typeof(Visibility), typeof(NavigationPane),
new PropertyMetadata(Visibility.Visible));
public Visibility IsBusyVisible
{
get { return (Visibility)GetValue(IsBusyVisibleProperty); }
set { SetValue(IsBusyVisibleProperty, value); }
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks. This make much more sense. So I extracted all the Nav stuff into a demo project to get it out of my app, and I still can get this to work. It looks like the panes never get added.
I put it in a repo here[^].
I would appreciate more help if you wouldn't mind.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
modified 16-Apr-23 18:57pm.
|
|
|
|
|