Skip to content

Commit 3da24a4

Browse files
Merge pull request #53 from AndrewKeepCoding/fix-numberboxex-min-width
Fix NumberBoxEx MinWidth
2 parents a68b06c + 9d47b1a commit 3da24a4

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

WinUI3/AK.Toolkit.WinUI3.NumberBoxEx/AK.Toolkit.WinUI3.NumberBoxEx.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
- NumberHorizontalAlignment DependencyProperty
1616
- IsDeleteButtonVisible DependencyProperty
1717
</Description>
18-
<Version>1.0.0</Version>
18+
<Version>1.0.1</Version>
1919
<PackageTags>winui3;winappsdk;numberbox;control;customcontrol</PackageTags>
2020
<PackageProjectUrl>https://github.com/AndrewKeepCoding/AK.Toolkit</PackageProjectUrl>
2121
<RepositoryUrl>https://github.com/AndrewKeepCoding/AK.Toolkit</RepositoryUrl>
@@ -25,7 +25,7 @@
2525
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
2626
<PackageId>AK.Toolkit.WinUI3.NumberBoxEx</PackageId>
2727
<Product>AK.Toolkit.WinUI3.NumberBoxEx</Product>
28-
<Copyright>Copyright (c) Andrew KeepCoding 2023</Copyright>
28+
<Copyright>Copyright (c) Andrew KeepCoding 2024</Copyright>
2929
<Authors>Andrew KeepCoding</Authors>
3030
<PackageReadMeFile>README.md</PackageReadMeFile>
3131
<PackageIcon>winui.png</PackageIcon>

WinUI3/AK.Toolkit.WinUI3.NumberBoxEx/NumberBoxEx.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Microsoft.UI.Xaml;
22
using Microsoft.UI.Xaml.Controls;
3+
using Microsoft.UI.Xaml.Data;
34
using Microsoft.UI.Xaml.Media;
45
using System.Collections.Generic;
56
using System.Linq;
@@ -42,6 +43,8 @@ public bool IsDeleteButtonVisible
4243

4344
private ScrollViewer? ContentElement { get; set; }
4445

46+
private TextBox? InputBox { get; set; }
47+
4548
private Button? DeleteButton { get; set; }
4649

4750
private long DeleteButtonPropertyChangedCallbackToken { get; set; }
@@ -82,6 +85,21 @@ private void NumberBoxEx_Loaded(object sender, RoutedEventArgs e)
8285
UpdateNumberHorizontalAlignment();
8386
}
8487

88+
if (FindChildrenOfType<TextBox>(this)
89+
.Where(x => x.Name == nameof(InputBox))
90+
.FirstOrDefault() is TextBox inputBox)
91+
{
92+
InputBox = inputBox;
93+
InputBox.SetBinding(
94+
TextBox.MinWidthProperty,
95+
new Binding
96+
{
97+
Source = this,
98+
Path = new PropertyPath("MinWidth"),
99+
Mode = BindingMode.OneWay,
100+
});
101+
}
102+
85103
if (FindChildrenOfType<Button>(this)
86104
.Where(x => x.Name == nameof(DeleteButton))
87105
.FirstOrDefault() is Button deleteButton)
@@ -123,4 +141,4 @@ private void NumberBoxEx_LostFocus(object sender, RoutedEventArgs e)
123141
DeleteButton.Visibility = Visibility.Collapsed;
124142
}
125143
}
126-
}
144+
}

0 commit comments

Comments
 (0)