Samsung / Tizen.CircularUI

Tizen Wearable CircularUI project is to develop an open source software motivate software developer to creating Tizen Wearable Xamarin Forms app more easily and efficiently.
Other
80 stars 32 forks source link

Backing data bound to Ui objects fail to redraw screen #351

Closed axa88 closed 3 years ago

axa88 commented 3 years ago

Describe the bug Objects such as Switch, CheckBox implementing INotifyPropertyChanged notification and bound to backing data does not for UI redraw when bound data is updated.

UI objects Label and CheckBox are utilized in the list cells of a CircleListView, and it is found that only when the backing data of the Label will force a UI update, the CheckBox does not. To see the change you will have to touch the screen forcing a redraw. That should not be necessary.

To Reproduce Create a CircleListView with ItemSource cells bound to a Label bound to backing data and a CheckBox or Switch bound to backing data both implementing INotifyPropertyChanged triggering OnPropertyChanged.

PrimaryText = new Label
{
    FontSize = cellStructure.PrimaryDefaultTextSize,
    HorizontalOptions = LayoutOptions.Center,
    VerticalOptions = LayoutOptions.Center,
    HorizontalTextAlignment = TextAlignment.Center,
    VerticalTextAlignment = TextAlignment.Center,
    HeightRequest = cellStructure.DualLines ? cellStructure.CellHeight * PrimaryHeightRatio : cellStructure.CellHeight
};
PrimaryText.SetBinding(Label.TextProperty, nameof(ListCellViewModel.PrimaryText));

and creating CheckBox or Switch and binding it to the view model:

RightButton = new CheckBox
{
    WidthRequest = 75,
    HeightRequest = 75,
    HorizontalOptions = LayoutOptions.End,
    VerticalOptions = LayoutOptions.Center,
    BackgroundColor = Color.Transparent,
    Scale = .75,
    Margin = new Thickness(0,0,10,0)
};
RightButton.SetBinding(CheckBox.IsCheckedProperty, nameof(ListCellViewModel.ButtonRight));

Note Items are not Added, Removed, Moved ect, from the ObservableCollection, and i do not wish to force to list to redraw entirely, only the updated items.

ItemCollection = new ObservableCollection<ListCellViewModel>();

Members of ListCellViewModel:

public string PrimaryText
{
    get => _primaryText;
    set
    {
        if (_primaryText != value)
        {
            _primaryText = value;
            OnPropertyChanged();
        }
    }
}

public virtual bool ButtonRight
{
    get => _buttonRight;
    set
    {
        if (_buttonRight != value)
        {
            _buttonRight = value;
            OnPropertyChanged();
        }
    }
}

When only the CheckBox data is updated, the screen will not redraw until something else forces it to redraw such as scrolling the list. UiRedrawFail

Expected behavior It is expected backing data should be able to update a listview items without manual interactoin when its binding data updates as it does in this Label: UiRedrawPass

But it does not with a CheckBox or Switch:

Environment (please complete the following information):

rookiejava commented 3 years ago

Could you share the code you tested? (Providing the project file helps us a lot. :-)) Actually, CheckBox and Switch is not a part of the CircularUI, but let's check.

axa88 commented 3 years ago

Actually, CheckBox and Switch is not a part of the CircularUI, but let's check.

Of course you are correct, im only using forms with CircularUI now so i am narrow minded.

(Providing the project file helps us a lot. :-))

Understood. I need to concider how to share without exposing any closed api information. Creating sanitized examples takes much time...

myroot commented 3 years ago

@axa88 Hi, I can't reproduce it It is working well checkbox-binding

Here is my test code https://gist.github.com/myroot/5d483638ebb4d7ac39aa3b6416d55ad9 CircleListBinding.zip

myroot commented 3 years ago

Please remove Scale on CheckBox, It seems issue related Scale property

axa88 commented 3 years ago

@myroot Scale property should not be used for CheckBox, or should not be used with Galaxy wearable at all?

Regardless i have checked your example and see it working with and without Scale used. I will try to close and reopen new issue if i see a problem. thanks for quick response.

myroot commented 3 years ago

@axa88 It's only CheckBox issue