maui
maui copied to clipboard
Binding works in Debug Mode but fails in Release Mode
Description
I created a custom control—nothing too fancy, just a TagButton control—and I binded the ViewModel's Command to it. The root is a ContentPage. In Debug mode, it works well, but in Release, nothing happens.
Here is the XAML code:
<ScrollView
HorizontalScrollBarVisibility="Never"
Orientation="Horizontal"
VerticalScrollBarVisibility="Never"
Visual="Default">
<HorizontalStackLayout BindableLayout.ItemsSource="{x:Binding FilterCategories, Mode=OneWay}">
<BindableLayout.ItemTemplate>
<DataTemplate x:DataType="{x:Type localmodel:EnumItem}">
<control:FieldTag
Margin="10,0,0,0"
Padding="10,5"
BorderColor="{x:StaticResource PrimaryDark}"
CheckedCommand="{x:Binding Source={x:Reference Root},
Path=ViewModel.FilterSelectedCommand,
Mode=OneWay}"
CheckedCommandParameter="{x:Binding .}"
CornerRadius="20"
HasShadow="False"
IsChecked="{x:Binding IsChecked,
Mode=TwoWay}"
IsCheckedBackgroundColor="{x:StaticResource PrimaryDark}"
IsUnCheckedBackgroundColor="{x:AppThemeBinding Dark=Transparent,
Light={x:StaticResource White}}"
MinimumWidthRequest="80"
Text="{x:Binding DisplayValue,
Mode=OneTime}"
TextColor="{x:StaticResource Primary}" />
</DataTemplate>
</BindableLayout.ItemTemplate>
</HorizontalStackLayout>
</ScrollView>
After I changed the Binding to:
CheckedCommand="{x:Binding Source={x:RelativeSource AncestorType={x:Type vm:RouteListViewModel}},
Path=FilterSelectedCommand,
Mode=OneWay}"
It's now working in both Debug and Release modes.
Steps to Reproduce
No response
Link to public reproduction project repository
No response
Version with bug
7.0.101
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 9.0-API 28
Did you find any workaround?
Yes, changed the binding style.
Relevant log output
No response
@roleemosh
Thanks for the feedback, but would you be so kind and create repro sample please?
@roleemosh
Thanks for the feedback, but would you be so kind and create repro sample please?
Sure, here is the repo: https://github.com/roleemosh/BindingFail
Verified this on Visual Studio Enterprise 17.9.0 Preview 2. This issue repro on 7.0.101, but does not repro on 8.0.3 on Android 13.0-API33. Repro project: BindingFail.zip
Android 13.0-API33(Version 8.0.3):
Android 13.0-API33(Version 7.0.101):
Hi @roleemosh. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.
You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.
This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.