-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid wrong inputs and enhance handling.
- Loading branch information
1 parent
522d81e
commit 86d4f61
Showing
12 changed files
with
87 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
LigaManagerAdminClient/Framework/SetMinWidthToAutoAttachedBehaviour.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
|
||
namespace LigaManagerAdminClient.Framework | ||
{ | ||
public class SetMinWidthToAutoAttachedBehaviour | ||
{ | ||
public static bool GetSetMinWidthToAuto(DependencyObject obj) | ||
{ | ||
return (bool)obj.GetValue(SetMinWidthToAutoProperty); | ||
} | ||
|
||
public static void SetSetMinWidthToAuto(DependencyObject obj, bool value) | ||
{ | ||
obj.SetValue(SetMinWidthToAutoProperty, value); | ||
} | ||
|
||
// Using a DependencyProperty as the backing store for SetMinWidthToAuto. This enables animation, styling, binding, etc... | ||
public static readonly DependencyProperty SetMinWidthToAutoProperty = | ||
DependencyProperty.RegisterAttached("SetMinWidthToAuto", typeof(bool), typeof(SetMinWidthToAutoAttachedBehaviour), new UIPropertyMetadata(false, WireUpLoadedEvent)); | ||
|
||
public static void WireUpLoadedEvent(DependencyObject d, DependencyPropertyChangedEventArgs e) | ||
{ | ||
var grid = (DataGrid)d; | ||
|
||
var doIt = (bool)e.NewValue; | ||
|
||
if (doIt) | ||
{ | ||
grid.Loaded += SetMinWidths; | ||
} | ||
} | ||
|
||
public static void SetMinWidths(object source, EventArgs e) | ||
{ | ||
var grid = (DataGrid)source; | ||
|
||
foreach (var column in grid.Columns) | ||
{ | ||
column.MinWidth = column.ActualWidth; | ||
column.Width = new DataGridLength(1, DataGridLengthUnitType.Star); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters