Skip to content

Commit d4aecc7

Browse files
Menuflyout fix (#292)
Currently when number of MenuFlyoutItem change, they don't reflect in the MenuFlyout as expected. For example, if you have a MenuFlyout that looks like this: ![image](https://github.com/user-attachments/assets/53535c1e-6fe3-445f-b8a6-b80a4d4e67a1) Then something changes that removes Feedback on recommendation to be removed, the MenuFlyout appears like this: ![image](https://github.com/user-attachments/assets/2e760454-7f3b-4b16-b6c7-bd4ac8c7b98b) instead of like this: ![image](https://github.com/user-attachments/assets/84920501-e6fc-4d3b-bd46-8f9f89c9cc2d) This PR fixes this issue. ###### Microsoft Reviewers: [Open in CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/microsoft/react-native-xaml/pull/292) --------- Co-authored-by: Jon Thysell <[email protected]>
1 parent 853a1fa commit d4aecc7

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "patch",
3+
"comment": {
4+
"title": "MenuFlyout fix"
5+
},
6+
"packageName": "react-native-xaml",
7+
"email": "[email protected]",
8+
"dependentChangeType": "patch"
9+
}

package/windows/ReactNativeXaml/XamlViewManager.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,12 @@ void XamlViewManager::RemoveChildAt(xaml::FrameworkElement parent, int64_t index
346346
return panel.Children().RemoveAt(static_cast<uint32_t>(index));
347347
} else if (auto itemsControl = e.try_as<ItemsControl>()) {
348348
return itemsControl.Items().RemoveAt(static_cast<uint32_t>(index));
349+
} else if (auto wrapper = e.try_as<Wrapper>()) {
350+
if (auto parentContent = wrapper.WrappedObject()) {
351+
if (auto menuFlyout = parentContent.try_as<MenuFlyout>()) {
352+
return menuFlyout.Items().RemoveAt(static_cast<uint32_t>(index));
353+
}
354+
}
349355
} else if (index == 0) {
350356
if (auto contentCtrl = e.try_as<ContentControl>()) {
351357
return contentCtrl.Content(nullptr);

0 commit comments

Comments
 (0)