maui icon indicating copy to clipboard operation
maui copied to clipboard

[regression/8.0.3] DataTrigger do not restore the original value anymore

Open omghb opened this issue 1 year ago • 5 comments

Description

DataTrigger does not restore the original value when the condition is becoming false.

This worked in MAUI 7. After migration to MAUI 8 we see new bugs in our App because of this issue.

Steps to Reproduce

  1. Create MAUI App and select 8.0
  2. Open MainPage.xaml and replace content with
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiDataTriggerIssue.MainPage">

    <ScrollView>
        <VerticalStackLayout Padding="30,0" Spacing="25">
            <Label Text="Disable button:"/>
            <CheckBox x:Name="testCheck"/>

            <Button x:Name="CounterBtn" Text="Click me" Clicked="OnCounterClicked">
                <Button.Triggers>
                    <DataTrigger Binding="{Binding IsChecked, Source={x:Reference testCheck}}" Value="True" TargetType="Button">
                        <Setter Property="IsEnabled" Value="False"/>
                    </DataTrigger>
                </Button.Triggers>
            </Button>
        </VerticalStackLayout>
    </ScrollView>

</ContentPage>
  1. Run the App on Windows
  2. See that Button is enabled and works
  3. Click on CheckBox -> Button get disabled
  4. Click again on CheckBox

Expected behavior: Button should get enabled again. Actual behavior: Button stays disabled.


DataTriggerIssue

Link to public reproduction project repository

No response

Version with bug

8.0.3

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

7.0.96

Affected platforms

iOS, Android, Windows

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

omghb avatar Nov 23 '23 10:11 omghb

This issue might be related to this one:

  • https://github.com/dotnet/maui/issues/17597

omghb avatar Nov 27 '23 09:11 omghb

@StephaneDelcroix thoughts?

mattleibow avatar Nov 29 '23 22:11 mattleibow

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

ghost avatar Nov 29 '23 22:11 ghost

Verified this on Visual Studio Enterprise 17.9.0 Preview 2(8.0.3). Repro on Windows 11, Android 14.0-API34, iOS 17.0 and MacCatalyst with below Project: 18976.zip

XamlTest avatar Dec 28 '23 03:12 XamlTest

i'm facing the exact same problem

ShariatPanah avatar Jan 07 '24 20:01 ShariatPanah

I can not reproduce this on top of (today's) main branch. Looks like it was fixed already. I'm pushing a pr with a unit test nd closing this

StephaneDelcroix avatar Jan 09 '24 14:01 StephaneDelcroix

i'm facing the exact same problem

You can try the latest MAUI nightly build to test if the issue is fixed for you or not.

MartyIX avatar Jan 10 '24 17:01 MartyIX

@MartyIX Sorry i'm not familiar with Nightly Builds, do i need to add some configuration in my project or something?

ShariatPanah avatar Jan 12 '24 16:01 ShariatPanah

@MartyIX Sorry i'm not familiar with Nightly Builds, do i need to add some configuration in my project or something?

Hey, it's described in the link I posted.

Basically, there are nuget packages here and you need to link it in your project so that you can test the latest MAUI version from git main branch.

MartyIX avatar Jan 13 '24 19:01 MartyIX

@MartyIX Sorry i'm not familiar with Nightly Builds, do i need to add some configuration in my project or something?

Hey, it's described in the link I posted.

Basically, there are nuget packages here and you need to link it in your project so that you can test the latest MAUI version from git main branch.

I tried searching these packages through Nuget Package Manager, but couldn't find them i even turned on the Include Prerelease checkbox, but with no luck.

then tried editing my .csproj file and replaced the:

<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />

with these two lines:

<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.6-nightly.9863" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.6-nightly.9863" />

but the compiler gives me errors and is complaining about couldn't find these packages and about AndroidManifest file, here's a screenshot: image

so am i doing something wrong?

ShariatPanah avatar Jan 14 '24 15:01 ShariatPanah

It sounds you are doing the correct thing and the only missing part is that you need to set https://pkgs.dev.azure.com/xamarin/public/_packaging/maui-nightly/nuget/v3/index.json in your NuGet.config file (see an example of such file here). Mine looks like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />

    <!-- See https://github.com/dotnet/maui/wiki/Nightly-Builds. -->
    <add key=".NET MAUI nightly" value="https://pkgs.dev.azure.com/xamarin/public/_packaging/maui-nightly/nuget/v3/index.json" protocolVersion="3" />
  </packageSources>
</configuration>

MartyIX avatar Jan 14 '24 18:01 MartyIX

@MartyIX Thanks for your help, i added the PackageSource you pointed out to my Nuget.Config file and everything works fine and my project now gets compiled. I tested the DataTrigger and yes i can confirm that it works as expected. ✌️

ShariatPanah avatar Jan 14 '24 21:01 ShariatPanah

Happy to hear that :)

MartyIX avatar Jan 14 '24 21:01 MartyIX