diff options
| author | Roy <roy.mail.net@gmail.com> | 2018-05-21 10:32:41 +0300 |
|---|---|---|
| committer | Roy <roy.mail.net@gmail.com> | 2018-05-21 10:32:41 +0300 |
| commit | e71176ddda34dd2303fbf6f183d2fe3f5af30c79 (patch) | |
| tree | 7184b738b71234281328ceea3c60a211ee4f816c /Software/Visual_Studio/Tango.SharedUI/Controls | |
| parent | c46f5f21663d6878f4aa94a0ebfd573845063c0f (diff) | |
| download | Tango-e71176ddda34dd2303fbf6f183d2fe3f5af30c79.tar.gz Tango-e71176ddda34dd2303fbf6f183d2fe3f5af30c79.zip | |
Working on touch keyboard.
Diffstat (limited to 'Software/Visual_Studio/Tango.SharedUI/Controls')
| -rw-r--r-- | Software/Visual_Studio/Tango.SharedUI/Controls/SpannedUniformGrid.cs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.SharedUI/Controls/SpannedUniformGrid.cs b/Software/Visual_Studio/Tango.SharedUI/Controls/SpannedUniformGrid.cs new file mode 100644 index 000000000..29e2e32f7 --- /dev/null +++ b/Software/Visual_Studio/Tango.SharedUI/Controls/SpannedUniformGrid.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; + +namespace Tango.SharedUI.Controls +{ + public class SpannedUniformGrid : Grid + { + public SpannedUniformGrid() + { + this.Loaded += (_, __) => InvalidateGrid(); + } + + private void InvalidateGrid() + { + ColumnDefinitions.Clear(); + + int count = 0; + + foreach (var item in Children.OfType<UIElement>()) + { + count++; + int span = Grid.GetColumnSpan(item); + + if (span > 1) + { + count += span; + } + + Grid.SetColumn(item, count - 1); + } + + for (int i = 0; i < count; i++) + { + ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); + } + } + } +} |
