Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IsNullOrEmptyStateTrigger not working for ListView #4411

Open
5 of 21 tasks
fmccown opened this issue Dec 2, 2021 · 2 comments · May be fixed by #4426
Open
5 of 21 tasks

IsNullOrEmptyStateTrigger not working for ListView #4411

fmccown opened this issue Dec 2, 2021 · 2 comments · May be fixed by #4426
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior helpers ✋ In-PR 🚀
Projects
Milestone

Comments

@fmccown
Copy link

fmccown commented Dec 2, 2021

Describe the bug

The XAML below is for a UWP app uses a VisualStateManager with an IsNullOrEmptyStateTrigger from the Microsoft.Toolkit.Uwp.UI package. The trigger is supposed to disable the button when no items are selected from the ListView. However, the button always remains enabled. The ListView's SelectedItem should be null when nothing in the list is selected (nothing is selected when you first run the app).

<Page
    x:Class="UwpTriggerDemo.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:UwpTriggerDemo"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:triggers="using:Microsoft.Toolkit.Uwp.UI.Triggers"    
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <StackPanel>
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="ListViewStates">
                <VisualState x:Name="ListSomethingSelectedState" />
                <VisualState x:Name="ListNothingSelectedState">
                    <VisualState.StateTriggers>
                        <triggers:IsNullOrEmptyStateTrigger Value="{Binding SelectedItem, 
                            ElementName=myListView, Mode=OneWay}"/>
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Target="myButton.IsEnabled" Value="False" />
                    </VisualState.Setters>
                </VisualState>
            </VisualStateGroup>

        </VisualStateManager.VisualStateGroups>

        <ListView x:Name="myListView">
            <TextBlock Text="Item 1" />
            <TextBlock Text="Item 2" />
            <TextBlock Text="Item 3" />
        </ListView>
        <Button x:Name="myButton" Content="Click Me" />
    </StackPanel>
</Page>
  • Is this bug a regression in the toolkit? If so, what toolkit version did you last see it work:

Steps to Reproduce

  • Can this be reproduced in the Sample App? (Either in a sample as-is or with new XAML pasted in the editor.) If so, please provide custom XAML or steps to reproduce. If not, let us know why it can't be reproduced (e.g. more complex setup, environment, dependencies, etc...)

Steps to reproduce the behavior:

  1. Create a new Blank App (Universal Windows).
  2. Add the latest Microsoft.Toolkit.Uwp.UI package.
  3. Paste the XAML above into MainPage.xaml.
  4. Run the app and notice that no item is selected in the ListView, but the button is enabled.

Expected behavior

When you run the app, the IsNullOrEmptyStateTrigger should set myButton.IsEnabled = false until an item from the ListView is selected.

Screenshots

No screenshot is necessary.

Environment

NuGet Package(s):

Microsoft.Toolkit.Uwp.UI package (v7.1.2)

Package Version(s):

Windows 10 Build Number:

  • Fall Creators Update (16299)
  • April 2018 Update (17134)
  • October 2018 Update (17763)
  • May 2019 Update (18362)
  • May 2020 Update (19041)
  • Insider Build ({build_number})

App min and target version:

  • Fall Creators Update (16299)
  • April 2018 Update (17134)
  • October 2018 Update (17763)
  • May 2019 Update (18362)
  • May 2020 Update (19041)
  • Insider Build ({build_number})

Device form factor:

  • Desktop
  • Xbox
  • Surface Hub
  • IoT

Visual Studio version:

  • 2017 (15.{minor_version})
  • 2019 (16.8.3)
  • 2022 (17.{minor_version})

Additional context

N/A

@fmccown fmccown added the bug 🐛 An unexpected issue that highlights incorrect behavior label Dec 2, 2021
@ghost ghost added the needs triage 🔍 label Dec 2, 2021
@ghost
Copy link

ghost commented Dec 2, 2021

Hello fmccown, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

@XAML-Knight
Copy link
Contributor

Nice catch, @fmccown . A similar bug occurs in the toolkit's Sample App, for the IsNullOrEmptyStateTrigger sample page, if you set the trigger on the SelectedItem property of the ListBox.

@XAML-Knight XAML-Knight linked a pull request Dec 14, 2021 that will close this issue
11 tasks
@ghost ghost added the In-PR 🚀 label Dec 14, 2021
@michael-hawker michael-hawker added this to the 8.0 milestone Dec 14, 2021
@michael-hawker michael-hawker added this to Triage in Bugs 8.0 via automation Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior helpers ✋ In-PR 🚀
Projects
Bugs 8.0
Triage
Development

Successfully merging a pull request may close this issue.

3 participants