I have a DataTrigger for an Entry which is defined inside my ContentView.Resources. It should and change the color of the Entry when the Min value is greater than the corresponding Max value. This works so far as can be seen in the very beginning of the attached GIF.
There is a Model class StoreSelection which is bound to this StoreSelectionItemView and contains the Entry for the Min value and the Max value.
The DataTrigger should trigger during input of values and underneath set an IsValid property when these values change so that it can calculate a bool property value IsValid which is true when Max >= Min. The data model class is derived from ObservableObject:
#region Min Profit
private int _min = 0;
[Column(Order = 6)]
public int Min
{
get => _min;
set
{
SetProperty(ref _min, value);
OnPropertyChanged(nameof(IsValid));
}
}
#endregion
#region Max Profit
private int _max = 0;
[Column(Order = 7)]
public int Max
{
get => _max;
set
{
SetProperty(ref _max, value);
OnPropertyChanged(nameof(IsValid));
}
}
#endregion
...
#endregion
#region IsValid
[NotMapped]
[Column(Order = 9)]
public bool IsValid { get => Max >= Min; }
#endregion
Issue:
The issue is, as can be seen in the attached animation below, that after the first items were selected and the DataTrigger fires correctly and we deselect elements and add new ones, the DataTrigger fires on the first Entry without apparent reason and even if Min == Max it fires. This can be seen on iOS only:
Android:
Steps to Reproduce
Watch the animations
Click on Dotnet-Bot icon to open the BottomSheet menu
Select first and second item to add them. That's the ViewStoreSelectionItemView.xaml defined via DataTemplate in TabView1.xaml
See that initially the DataTrigger of the first Entry does not trigger, which is correct as the Min value is 0 and the Max value is 0
Type in some values and see that when Min > Max the DataTrigger fires correctly and changes the TextColor of the Entry
Click on Dotnet-Bot icon to open the BottomSheet again deselect the first item
Click on Dotnet-Bot icon to open the BottomSheet again and select the first item again
See that the DataTrigger of the first Entry fires and color is changed to the "Error"-Color even if the value is "0"
Try on iOS and Android and see that it behaves correctly just on Android
A workaround would be to use ObservableRangeCollection.Add(..., NotifyCollectionChangedAction.Reset) or use new ObservableRangeCollection() and so on. But all kinds of actions in which a NotifyCollectionChangedAction.Reset is involved result in rising memory consumption and finally crash my App on my iPhone without hitting any of the try-catch-Blocks wrapped around.
Description
I have a
DataTrigger
for anEntry
which is defined inside myContentView.Resources
. It should and change the color of theEntry
when the Min value is greater than the corresponding Max value. This works so far as can be seen in the very beginning of the attached GIF.The
DataTrigger
is defined as follows:The
ContentView
with theEntrys
is defined inside aDataTemplate
:There is a Model class
StoreSelection
which is bound to thisStoreSelectionItemView
and contains theEntry
for the Min value and the Max value.The
DataTrigger
should trigger during input of values and underneath set an IsValid property when these values change so that it can calculate abool
property value IsValid which istrue
whenMax >= Min
. The data model class is derived fromObservableObject
:Issue: The issue is, as can be seen in the attached animation below, that after the first items were selected and the
DataTrigger
fires correctly and we deselect elements and add new ones, theDataTrigger
fires on the first Entry without apparent reason and even ifMin == Max
it fires. This can be seen on iOS only:Android:
Steps to Reproduce
Watch the animations
View
StoreSelectionItemView.xaml defined viaDataTemplate
inTabView1.xaml
DataTrigger
of the firstEntry
does not trigger, which is correct as the Min value is 0 and the Max value is 0DataTrigger
fires correctly and changes theTextColor
of theEntry
DataTrigger
of the firstEntry
fires and color is changed to the "Error"-Color even if the value is "0"Link to public reproduction project repository
DataTriggerCorrupted_20927
Version with bug
8.0.6-nightly.9863 up to 8.0.10-nightly.10061
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
7.0.101
Affected platforms
iOS
Affected platform versions
iOS 17.2
Did you find any workaround?
Well, no working workaround in the end.
A workaround would be to use
ObservableRangeCollection.Add(..., NotifyCollectionChangedAction.Reset)
or usenew ObservableRangeCollection()
and so on. But all kinds of actions in which aNotifyCollectionChangedAction.Reset
is involved result in rising memory consumption and finally crash my App on my iPhone without hitting any ofthe try-catch
-Blocks wrapped around.I described this in detail in #21015
But, this would fix the issue and don't show the effect of this issue.
Relevant log output
No response