-
Notifications
You must be signed in to change notification settings - Fork 803
Open
Labels
bugSomething isn't workingSomething isn't workingneeds-triageIssue needs to be triaged by the area ownersIssue needs to be triaged by the area owners
Description
Describe the bug
I am setting ContentPresenter.Content to some controls in a VisualState. It crashes the app on certain larger / more complex controls, but it's okay for basic Button.
It's kind of a weird and corner-case usage I know, but if it's by design it should be documented somewhere.
Steps to reproduce the bug
- Use this xaml
<StackPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Vertical">
<ComboBox Header="Select state:" SelectionChanged="ComboBox_SelectionChanged">
<x:String>State1</x:String>
<x:String>State2</x:String>
</ComboBox>
<ContentPresenter x:Name="Presenter" />
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="State1">
<VisualState.Setters>
<Setter Target="Presenter.Content">
<Setter.Value>
<CalendarView />
</Setter.Value>
</Setter>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="State2">
<VisualState.Setters>
<Setter Target="Presenter.Content">
<Setter.Value>
<Button
x:Name="State2Button"
Click="State2Button_Click"
Content="State 2 Button" />
</Setter.Value>
</Setter>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</StackPanel>- In code behind, you simply switch states according to the selected
ComboBoxitem.
void ComboBox_SelectionChanged(winrt::Windows::Foundation::IInspectable const& sender, winrt::Microsoft::UI::Xaml::Controls::SelectionChangedEventArgs const& e)
{
winrt::check_bool(winrt::Microsoft::UI::Xaml::VisualStateManager::GoToState(
*this,
sender.as<winrt::Microsoft::UI::Xaml::Controls::ComboBox>().SelectedItem().as<winrt::hstring>(),
false
));
}- Build and run. Switch the state from the comboBox the first time, it works without issue. But switch back to the same state, it crashes.
Expected behavior
No crash.
Screenshots
NuGet package version
WinUI 3 - Windows App SDK 1.6.3: 1.6.241114003
Windows version
Windows 11 (23H2): Build 22631
Additional context
This happens to UWP and WinUI3.
Repro
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingneeds-triageIssue needs to be triaged by the area ownersIssue needs to be triaged by the area owners
