diff --git a/Source/NETworkManager.Utilities.WPF/DataGridHelper.cs b/Source/NETworkManager.Utilities.WPF/DataGridHelper.cs
new file mode 100644
index 0000000000..1d2aaf1ba6
--- /dev/null
+++ b/Source/NETworkManager.Utilities.WPF/DataGridHelper.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Threading;
+
+namespace NETworkManager.Utilities.WPF;
+
+///
+/// Attached-property helpers for .
+///
+public static class DataGridHelper
+{
+ ///
+ /// When set to , forces star-sized columns to recompute their width after
+ /// the first row is realized. Without this, an initially empty sizes star
+ /// columns to MinWidth because the inner
+ /// measures with infinite width; only a window resize would otherwise trigger a correct re-measure.
+ /// The handler unsubscribes itself after the first row so there is no ongoing overhead.
+ ///
+ public static readonly DependencyProperty RefreshStarColumnsOnFirstRowProperty =
+ DependencyProperty.RegisterAttached(
+ "RefreshStarColumnsOnFirstRow",
+ typeof(bool),
+ typeof(DataGridHelper),
+ new PropertyMetadata(false, OnRefreshStarColumnsOnFirstRowChanged));
+
+ public static void SetRefreshStarColumnsOnFirstRow(DataGrid element, bool value) =>
+ element.SetValue(RefreshStarColumnsOnFirstRowProperty, value);
+
+ public static bool GetRefreshStarColumnsOnFirstRow(DataGrid element) =>
+ (bool)element.GetValue(RefreshStarColumnsOnFirstRowProperty);
+
+ private static void OnRefreshStarColumnsOnFirstRowChanged(DependencyObject d,
+ DependencyPropertyChangedEventArgs e)
+ {
+ if (d is not DataGrid dataGrid || e.NewValue is not bool enabled || !enabled)
+ return;
+
+ dataGrid.LoadingRow += Handler;
+ return;
+
+ void Handler(object sender, DataGridRowEventArgs args)
+ {
+ dataGrid.LoadingRow -= Handler;
+
+ dataGrid.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ foreach (var column in dataGrid.Columns)
+ {
+ if (!column.Width.IsStar)
+ continue;
+
+ var width = column.Width;
+ column.Width = 0;
+ column.Width = width;
+ }
+ }), DispatcherPriority.ContextIdle);
+ }
+ }
+}
diff --git a/Source/NETworkManager/Views/ConnectionsView.xaml b/Source/NETworkManager/Views/ConnectionsView.xaml
index b73fe87ba7..3374a8925e 100644
--- a/Source/NETworkManager/Views/ConnectionsView.xaml
+++ b/Source/NETworkManager/Views/ConnectionsView.xaml
@@ -11,7 +11,7 @@
xmlns:utilities="clr-namespace:NETworkManager.Utilities;assembly=NETworkManager.Utilities"
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
xmlns:controls="clr-namespace:NETworkManager.Controls;assembly=NETworkManager.Controls"
- xmlns:wpfHelper="clr-namespace:NETworkManager.Utilities.WPF;assembly=NETworkManager.Utilities.WPF"
+ xmlns:wpfHelpers="clr-namespace:NETworkManager.Utilities.WPF;assembly=NETworkManager.Utilities.WPF"
mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:ConnectionsViewModel}">
@@ -69,7 +69,7 @@
Style="{StaticResource CleanButton}"
Margin="0,0,10,0">
+ wpfHelpers:ReloadAnimationHelper.IsReloading="{Binding IsRefreshing}">
@@ -95,11 +95,13 @@
Style="{StaticResource ResourceKey=SearchTextBox}" />
-
+ Sorting="DataGrid_OnSorting"
+ wpfHelpers:DataGridHelper.RefreshStarColumnsOnFirstRow="True">
+ SortMemberPath="ProcessPath" MinWidth="150"
+ Width="*" />
@@ -84,7 +85,7 @@
+ SelectedItem="{Binding QueryType}" Width="100" HorizontalAlignment="Left" />
-
-
-
-
-
-
-
-
-
+
@@ -100,6 +88,7 @@
ItemsSource="{Binding ResultsView}"
SelectedItem="{Binding SelectedResult}"
SelectedItemsList="{Binding SelectedResults, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+ wpfHelpers:DataGridHelper.RefreshStarColumnsOnFirstRow="True"
RowDetailsVisibilityMode="Collapsed">
@@ -401,7 +390,8 @@
+ MinWidth="100"
+ Width="*">
@@ -596,600 +586,5 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
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-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/Source/NETworkManager/Views/FirewallView.xaml.cs b/Source/NETworkManager/Views/FirewallView.xaml.cs
index 7b89181733..aa92079beb 100644
--- a/Source/NETworkManager/Views/FirewallView.xaml.cs
+++ b/Source/NETworkManager/Views/FirewallView.xaml.cs
@@ -1,4 +1,5 @@
-using System.Windows;
+using System;
+using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using NETworkManager.ViewModels;
@@ -68,5 +69,6 @@ public void OnViewVisible()
{
_viewModel.OnViewVisible();
}
+
#endregion
}
diff --git a/Source/NETworkManager/Views/HostsFileEditorView.xaml b/Source/NETworkManager/Views/HostsFileEditorView.xaml
index f70d7c1830..d4e176e76d 100644
--- a/Source/NETworkManager/Views/HostsFileEditorView.xaml
+++ b/Source/NETworkManager/Views/HostsFileEditorView.xaml
@@ -11,7 +11,7 @@
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
xmlns:settings="clr-namespace:NETworkManager.Settings;assembly=NETworkManager.Settings"
xmlns:mahAppsControls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
- xmlns:wpfHelper="clr-namespace:NETworkManager.Utilities.WPF;assembly=NETworkManager.Utilities.WPF"
+ xmlns:wpfHelpers="clr-namespace:NETworkManager.Utilities.WPF;assembly=NETworkManager.Utilities.WPF"
xmlns:controls="clr-namespace:NETworkManager.Controls;assembly=NETworkManager.Controls"
mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:HostsFileEditorViewModel}">
@@ -53,7 +53,7 @@
Style="{StaticResource CleanButton}"
Margin="0,0,10,0">
+ wpfHelpers:ReloadAnimationHelper.IsReloading="{Binding IsRefreshing}">
diff --git a/Source/NETworkManager/Views/IPScannerView.xaml b/Source/NETworkManager/Views/IPScannerView.xaml
index d157d218c7..0d7301ded9 100644
--- a/Source/NETworkManager/Views/IPScannerView.xaml
+++ b/Source/NETworkManager/Views/IPScannerView.xaml
@@ -218,11 +218,13 @@
-
+ MinWidth="200"
+ Width="*">
@@ -68,7 +68,7 @@
Style="{StaticResource CleanButton}"
Margin="0,0,10,0">
+ wpfHelpers:ReloadAnimationHelper.IsReloading="{Binding IsRefreshing}">
@@ -94,11 +94,13 @@
Style="{StaticResource ResourceKey=SearchTextBox}" />
-
+ Sorting="DataGrid_OnSorting"
+ wpfHelpers:DataGridHelper.RefreshStarColumnsOnFirstRow="True">
diff --git a/Source/NETworkManager/Views/ListenersView.xaml.cs b/Source/NETworkManager/Views/ListenersView.xaml.cs
index a8a1579ae0..f1b2eff3e1 100644
--- a/Source/NETworkManager/Views/ListenersView.xaml.cs
+++ b/Source/NETworkManager/Views/ListenersView.xaml.cs
@@ -1,4 +1,5 @@
-using System.Collections;
+using System;
+using System.Collections;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
diff --git a/Source/NETworkManager/Views/LookupOUILookupView.xaml b/Source/NETworkManager/Views/LookupOUILookupView.xaml
index 829bc4dc21..58684519fd 100644
--- a/Source/NETworkManager/Views/LookupOUILookupView.xaml
+++ b/Source/NETworkManager/Views/LookupOUILookupView.xaml
@@ -12,6 +12,7 @@
xmlns:lookup="clr-namespace:NETworkManager.Models.Lookup;assembly=NETworkManager.Models"
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
xmlns:controls="clr-namespace:NETworkManager.Controls;assembly=NETworkManager.Controls"
+ xmlns:wpfHelpers="clr-namespace:NETworkManager.Utilities.WPF;assembly=NETworkManager.Utilities.WPF"
mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:LookupOUILookupViewModel}">
@@ -103,9 +104,11 @@
Style="{DynamicResource DefaultTextBlock}" Margin="0,10,0,0" />
-
+ SelectedItemsList="{Binding SelectedResults, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+ wpfHelpers:DataGridHelper.RefreshStarColumnsOnFirstRow="True">
+ MinWidth="200"
+ Width="*" />
diff --git a/Source/NETworkManager/Views/LookupOUILookupView.xaml.cs b/Source/NETworkManager/Views/LookupOUILookupView.xaml.cs
index 3ac1334242..55fb466ff3 100644
--- a/Source/NETworkManager/Views/LookupOUILookupView.xaml.cs
+++ b/Source/NETworkManager/Views/LookupOUILookupView.xaml.cs
@@ -1,4 +1,5 @@
-using System.Windows;
+using System;
+using System.Windows;
using System.Windows.Controls;
using NETworkManager.ViewModels;
diff --git a/Source/NETworkManager/Views/LookupPortLookupView.xaml b/Source/NETworkManager/Views/LookupPortLookupView.xaml
index d40ec3439c..229f4f6946 100644
--- a/Source/NETworkManager/Views/LookupPortLookupView.xaml
+++ b/Source/NETworkManager/Views/LookupPortLookupView.xaml
@@ -12,6 +12,7 @@
xmlns:lookup="clr-namespace:NETworkManager.Models.Lookup;assembly=NETworkManager.Models"
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
xmlns:controls="clr-namespace:NETworkManager.Controls;assembly=NETworkManager.Controls"
+ xmlns:wpfHelpers="clr-namespace:NETworkManager.Utilities.WPF;assembly=NETworkManager.Utilities.WPF"
mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:LookupPortLookupViewModel}">
@@ -102,9 +103,11 @@
Style="{DynamicResource DefaultTextBlock}" Margin="0,10,0,0" />
-
+ SelectedItemsList="{Binding SelectedResults, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+ wpfHelpers:DataGridHelper.RefreshStarColumnsOnFirstRow="True">
+ SortMemberPath="Description"
+ MinWidth="200"
+ Width="*">
+
+
+
+
diff --git a/Source/NETworkManager/Views/LookupPortLookupView.xaml.cs b/Source/NETworkManager/Views/LookupPortLookupView.xaml.cs
index 21aeb0cda2..e27e35183c 100644
--- a/Source/NETworkManager/Views/LookupPortLookupView.xaml.cs
+++ b/Source/NETworkManager/Views/LookupPortLookupView.xaml.cs
@@ -1,4 +1,5 @@
-using System.Windows;
+using System;
+using System.Windows;
using System.Windows.Controls;
using NETworkManager.ViewModels;
diff --git a/Source/NETworkManager/Views/NeighborTableView.xaml b/Source/NETworkManager/Views/NeighborTableView.xaml
index 0497fa3e5a..df4217cc7d 100644
--- a/Source/NETworkManager/Views/NeighborTableView.xaml
+++ b/Source/NETworkManager/Views/NeighborTableView.xaml
@@ -11,7 +11,7 @@
xmlns:networkManager="clr-namespace:NETworkManager"
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
xmlns:controls="clr-namespace:NETworkManager.Controls;assembly=NETworkManager.Controls"
- xmlns:wpfHelper="clr-namespace:NETworkManager.Utilities.WPF;assembly=NETworkManager.Utilities.WPF"
+ xmlns:wpfHelpers="clr-namespace:NETworkManager.Utilities.WPF;assembly=NETworkManager.Utilities.WPF"
xmlns:settings="clr-namespace:NETworkManager.Settings;assembly=NETworkManager.Settings"
x:Class="NETworkManager.Views.NeighborTableView"
d:DataContext="{d:DesignInstance {x:Type viewModels:NeighborTableViewModel}}"
@@ -78,7 +78,7 @@
Style="{StaticResource CleanButton}"
Margin="0,0,10,0">
+ wpfHelpers:ReloadAnimationHelper.IsReloading="{Binding IsRefreshing}">
@@ -109,7 +109,8 @@
ItemsSource="{Binding ResultsView}"
SelectedItem="{Binding SelectedResult}"
SelectedItemsList="{Binding SelectedResults, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
- Sorting="DataGrid_OnSorting">
+ Sorting="DataGrid_OnSorting"
+ wpfHelpers:DataGridHelper.RefreshStarColumnsOnFirstRow="True">
+ MinWidth="200" />
+ MinWidth="180" />
+ MinWidth="100"
+ Width="*" />
diff --git a/Source/NETworkManager/Views/NeighborTableView.xaml.cs b/Source/NETworkManager/Views/NeighborTableView.xaml.cs
index 096a60667e..90a839be56 100644
--- a/Source/NETworkManager/Views/NeighborTableView.xaml.cs
+++ b/Source/NETworkManager/Views/NeighborTableView.xaml.cs
@@ -1,3 +1,4 @@
+using System;
using System.Collections;
using System.ComponentModel;
using System.Windows;
diff --git a/Source/NETworkManager/Views/PortScannerView.xaml b/Source/NETworkManager/Views/PortScannerView.xaml
index 739cf1e691..45fed20bdd 100644
--- a/Source/NETworkManager/Views/PortScannerView.xaml
+++ b/Source/NETworkManager/Views/PortScannerView.xaml
@@ -13,6 +13,7 @@
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
xmlns:controls="clr-namespace:NETworkManager.Controls;assembly=NETworkManager.Controls"
xmlns:settings="clr-namespace:NETworkManager.Settings;assembly=NETworkManager.Settings"
+ xmlns:wpfHelpers="clr-namespace:NETworkManager.Utilities.WPF;assembly=NETworkManager.Utilities.WPF"
Loaded="UserControl_Loaded"
mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:PortScannerViewModel}">
@@ -40,11 +41,11 @@
-
+
-
+
@@ -223,9 +224,11 @@
Style="{DynamicResource StatusMessageTextBlock}" Margin="0,10,0,0" />
-
+ MinWidth="200"
+ Width="*" />
diff --git a/Source/NETworkManager/Views/SNMPView.xaml b/Source/NETworkManager/Views/SNMPView.xaml
index 991545ba42..283800b3c5 100644
--- a/Source/NETworkManager/Views/SNMPView.xaml
+++ b/Source/NETworkManager/Views/SNMPView.xaml
@@ -617,11 +617,13 @@
-
+ SelectedItemsList="{Binding SelectedResults, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+ wpfHelpers:DataGridHelper.RefreshStarColumnsOnFirstRow="True">
+ SortMemberPath="Data"
+ MinWidth="300"
+ Width="*">
+
+
+
+
@@ -113,11 +114,13 @@
-
+ SelectedItemsList="{Binding Path=SelectedResults, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+ wpfHelpers:DataGridHelper.RefreshStarColumnsOnFirstRow="True">
+ MinWidth="80"
+ Width="*" />
diff --git a/Source/NETworkManager/Views/SubnetCalculatorSubnettingView.xaml b/Source/NETworkManager/Views/SubnetCalculatorSubnettingView.xaml
index c57be5bfb4..857e1b4302 100644
--- a/Source/NETworkManager/Views/SubnetCalculatorSubnettingView.xaml
+++ b/Source/NETworkManager/Views/SubnetCalculatorSubnettingView.xaml
@@ -11,6 +11,7 @@
xmlns:localization="clr-namespace:NETworkManager.Localization.Resources;assembly=NETworkManager.Localization"
xmlns:controls="clr-namespace:NETworkManager.Controls;assembly=NETworkManager.Controls"
xmlns:network="clr-namespace:NETworkManager.Models.Network;assembly=NETworkManager.Models"
+ xmlns:wpfHelpers="clr-namespace:NETworkManager.Utilities.WPF;assembly=NETworkManager.Utilities.WPF"
mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:SubnetCalculatorSubnettingViewModel}">
@@ -139,10 +140,12 @@
-
+ SelectedItemsList="{Binding SelectedResults, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+ wpfHelpers:DataGridHelper.RefreshStarColumnsOnFirstRow="True">
+ MinWidth="80"
+ Width="*" />
@@ -142,9 +143,11 @@
-
+ SelectedItemsList="{Binding SelectedResults, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+ wpfHelpers:DataGridHelper.RefreshStarColumnsOnFirstRow="True">
+ MinWidth="150"
+ Width="*" />
@@ -171,7 +171,7 @@
Style="{StaticResource CleanButton}"
Margin="10,0,0,0">
+ wpfHelpers:ReloadAnimationHelper.IsReloading="{Binding IsAdaptersLoading}">
@@ -243,7 +243,7 @@
Style="{StaticResource CleanButton}"
Margin="0,0,10,0">
+ wpfHelpers:ReloadAnimationHelper.IsReloading="{Binding Path=IsBackgroundSearchRunning}">
@@ -280,11 +280,13 @@
-
+ SelectedItemsList="{Binding Path=SelectedNetworks, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
+ wpfHelpers:DataGridHelper.RefreshStarColumnsOnFirstRow="True">
@@ -568,7 +570,8 @@
+ SortMemberPath="AvailableNetwork.Ssid"
+ MinWidth="150">