|
3 | 3 | // MUX Reference controls\dev\CommandBarFlyout\CommandBarFlyout.cpp, tag winui3/release/1.7.3, commit 65718e2813a90fc900e8775d2ddc580b268fcc2f |
4 | 4 |
|
5 | 5 | using System; |
| 6 | +using System.Numerics; |
| 7 | +using Microsoft.UI.Xaml.Automation.Peers; |
6 | 8 | using Microsoft.UI.Xaml.Controls.Primitives; |
| 9 | +using Microsoft.UI.Xaml.Media; |
7 | 10 | using Uno.Disposables; |
8 | 11 | using Uno.UI.DataBinding; |
9 | 12 | using Uno.UI.Helpers.WinUI; |
10 | 13 | using Windows.Foundation.Collections; |
11 | | -using Microsoft.UI.Xaml; |
12 | | -using Microsoft.UI.Xaml.Automation.Peers; |
13 | | -using Microsoft.UI.Xaml.Controls; |
14 | | -using Microsoft.UI.Xaml.Media; |
15 | 14 | using static Microsoft.UI.Xaml.Controls._Tracing; |
16 | 15 | using CommandBarFlyoutCommandBar = Microsoft.UI.Xaml.Controls.Primitives.CommandBarFlyoutCommandBar; |
17 | | -using System.Numerics; |
18 | 16 |
|
19 | 17 | namespace Microsoft.UI.Xaml.Controls; |
20 | 18 |
|
@@ -195,32 +193,31 @@ void OnSecondaryCommandsChanged(IObservableVector<ICommandBarElement> sender, IV |
195 | 193 | } |
196 | 194 |
|
197 | 195 | SharedHelpers.QueueCallbackForCompositionRendering(() => |
| 196 | + { |
| 197 | + if (commandBar is { } commandBarFlyoutCommandBar) |
198 | 198 | { |
199 | | - if (commandBar is { } commandBarFlyoutCommandBar) |
| 199 | + using var scopeGuard = Disposable.Create(() => |
200 | 200 | { |
201 | | - using var scopeGuard = Disposable.Create(() => |
202 | | - { |
203 | | - commandBarFlyoutCommandBar.m_commandBarFlyoutIsOpening = false; |
204 | | - }); |
| 201 | + commandBarFlyoutCommandBar.m_commandBarFlyoutIsOpening = false; |
| 202 | + }); |
205 | 203 |
|
206 | | - commandBarFlyoutCommandBar.m_commandBarFlyoutIsOpening = true; |
| 204 | + commandBarFlyoutCommandBar.m_commandBarFlyoutIsOpening = true; |
207 | 205 |
|
208 | | - // If we don't have IFlyoutBase5 available, then we assume a standard show mode. |
209 | | - if (ShowMode == FlyoutShowMode.Standard) |
210 | | - { |
| 206 | + // If we don't have IFlyoutBase5 available, then we assume a standard show mode. |
| 207 | + if (ShowMode == FlyoutShowMode.Standard) |
| 208 | + { |
211 | 209 | #if HAS_UNO |
212 | | - // In case of Uno Platform, the callback is executed too early, before CommandBarFlyoutCommandBar.OnApplyTemplate. |
213 | | - // This causes unexpected behavior https://github.com/unoplatform/uno/issues/20984. To avoid this, we schedule the IsOpen change |
214 | | - // on the next tick. |
215 | | - DispatcherQueue.TryEnqueue(() => |
216 | | - { |
217 | | - commandBar.IsOpen = true; |
218 | | - }); |
| 210 | + // In case of Uno Platform, the callback is executed too early, before CommandBarFlyoutCommandBar.OnApplyTemplate. |
| 211 | + // This causes unexpected behavior https://github.com/unoplatform/uno/issues/20984. To avoid this, we schedule the IsOpen change |
| 212 | + // on the next tick. |
| 213 | + DispatcherQueue.TryEnqueue(() => |
| 214 | + { |
| 215 | + commandBar.IsOpen = true; |
| 216 | + }); |
219 | 217 | #endif |
220 | | - } |
221 | 218 | } |
222 | 219 | } |
223 | | - ); |
| 220 | + }); |
224 | 221 | } |
225 | 222 |
|
226 | 223 | if (m_primaryCommands.Count > 0) |
|
0 commit comments