Skip to content

Commit 5c76748

Browse files
committed
Call once function new implementation
1 parent 95a9817 commit 5c76748

3 files changed

Lines changed: 7 additions & 9 deletions

File tree

WinUI3Package/.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
33
<metadata>
44
<id>WinUIEssential.WinUI3</id>
5-
<version>1.3.13</version>
5+
<version>1.3.14</version>
66
<title>WinUIEssential(WinUI3)</title>
77
<authors>Peter</authors>
88
<owners></owners>

WinUI3Package/AutoSuggestBoxHelper.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,16 @@ namespace winrt::WinUI3Package::implementation
5252
return;
5353

5454
auto autoSuggestBox = object.as<winrt::Microsoft::UI::Xaml::Controls::AutoSuggestBox>();
55-
autoSuggestBox.LayoutUpdated([autoSuggestBoxRef = winrt::make_weak(autoSuggestBox), called = false](auto&&...) mutable
55+
auto layoutUpdatedRevoker = std::make_shared<winrt::Microsoft::UI::Xaml::Controls::AutoSuggestBox::LayoutUpdated_revoker>();
56+
*layoutUpdatedRevoker = autoSuggestBox.LayoutUpdated(winrt::auto_revoke, [autoSuggestBoxRef = winrt::make_weak(autoSuggestBox), layoutUpdatedRevoker](auto&&...)
5657
{
57-
if (called) return;
58-
5958
auto popup = VisualTreeHelper::FindVisualChildByName<winrt::Microsoft::UI::Xaml::Controls::Primitives::Popup>(
6059
autoSuggestBoxRef.get().as<winrt::Microsoft::UI::Xaml::Controls::AutoSuggestBox>(),
6160
L"SuggestionsPopup"
6261
);
6362
if (!popup) return;
6463

65-
called = true;
64+
layoutUpdatedRevoker->revoke();
6665
auto border = popup.FindName(L"SuggestionsContainer").as<winrt::Microsoft::UI::Xaml::Controls::Border>();
6766
border.Padding({});
6867
border.Background(winrt::Microsoft::UI::Xaml::Media::SolidColorBrush{ winrt::Windows::UI::Colors::Transparent() });

WinUI3Package/ComboBoxHelper.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,16 @@ namespace winrt::WinUI3Package::implementation
4646
return;
4747

4848
auto comboBox = object.as<winrt::Microsoft::UI::Xaml::Controls::ComboBox>();
49-
comboBox.LayoutUpdated([comboxBoxRef = winrt::make_weak(comboBox), called = false](auto&&...) mutable
49+
auto layoutUpdatedRevoker = std::make_shared<winrt::Microsoft::UI::Xaml::Controls::ComboBox::LayoutUpdated_revoker>();
50+
comboBox.LayoutUpdated([comboxBoxRef = winrt::make_weak(comboBox), layoutUpdatedRevoker](auto&&...) mutable
5051
{
51-
if (called) return;
52-
5352
auto popup = VisualTreeHelper::FindVisualChildByName<winrt::Microsoft::UI::Xaml::Controls::Primitives::Popup>(
5453
comboxBoxRef.get().as<winrt::Microsoft::UI::Xaml::Controls::ComboBox>(),
5554
L"Popup"
5655
);
5756
if (!popup) return;
5857

59-
called = true;
58+
layoutUpdatedRevoker->revoke();
6059
auto border = popup.FindName(L"PopupBorder").as<winrt::Microsoft::UI::Xaml::Controls::Border>();
6160
border.SizeChanged([comboxBoxRef, called = false, visualRef = winrt::weak_ref<winrt::WinUI3Package::AcrylicVisual>{}](auto const& borderRef, winrt::Microsoft::UI::Xaml::SizeChangedEventArgs const& args) mutable
6261
{

0 commit comments

Comments
 (0)