Bug 59905 - Frame does not apear
Summary: Frame does not apear
Status: CLOSED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms (show other bugs)
Version: 2.4.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-10-02 19:24 UTC by Roman
Modified: 2018-01-13 01:31 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
screenshot (84.90 KB, image/jpeg)
2017-10-02 20:21 UTC, Roman
Details
view application (111.08 KB, image/jpeg)
2017-10-02 20:24 UTC, Roman
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
CLOSED ANSWERED

Description Roman 2017-10-02 19:24:04 UTC
This is my code

public partial class HistoryPeriod : ContentPage
    {
        private Frame _frame;
        private StackLayout _stackDate;
        private RadioButton _radioButtonDay, _radioButtonMonth, _radioButtonPeriod, _radioButtonLastWeek;
        private DatePicker _datePickerFrom, _datePickerTo;
        public HistoryPeriod()
        {
            InitializeComponent();

            GroupBox groupBox = new GroupBox();
            _radioButtonDay = new RadioButton();
            _radioButtonDay.Text = Resource.forToday;

            _radioButtonLastWeek = new RadioButton();
            _radioButtonLastWeek.Text = Resource.lastWeek;
           
            _radioButtonMonth = new RadioButton();
            _radioButtonMonth.Text = Resource.forCurrentMonth;
            
            _radioButtonPeriod = new RadioButton();
            _radioButtonPeriod.Text = Resource.forSelectedPeriod;
            _radioButtonPeriod.OnChangeChecked += RadioButtonPeriod_OnChangeChecked;

            groupBox.Children.Add(_radioButtonDay);
            groupBox.Children.Add(_radioButtonLastWeek);
            groupBox.Children.Add(_radioButtonMonth);
            groupBox.Children.Add(_radioButtonPeriod);

            _frame = new Frame();
            _frame.BackgroundColor = Color.AliceBlue;
            _frame.IsVisible = false;

            _stackDate = new StackLayout();
            _stackDate.HeightRequest = 300;
            Label labelFromDate = new Label();
            labelFromDate.Text = Resource.fromDate;
            _datePickerFrom = new DatePicker();
            _datePickerFrom.Format = "D";
            _datePickerFrom.MinimumDate = new DateTime(2010, 1, 1);
            _datePickerFrom.MaximumDate = new DateTime(2083, 4, 27);
            _datePickerFrom.DateSelected += DatePicker_DateSelected;

            Label labelToDate = new Label();
            labelToDate.Text = Resource.toDate;
            _datePickerTo = new DatePicker();
            _datePickerTo.Format = "D";
            _datePickerTo.MinimumDate = new DateTime(2010, 1, 1);
            _datePickerTo.MaximumDate = new DateTime(2083, 4, 27);
            _datePickerTo.DateSelected += DatePicker_DateSelected;

            _stackDate.Children.Add(labelFromDate);
            _stackDate.Children.Add(_datePickerFrom);
            _stackDate.Children.Add(labelToDate);
            _stackDate.Children.Add(_datePickerTo);

            _frame.Content = _stackDate;

            Button butShow = new Button();
            butShow.Text = Resource.show;
            butShow.BorderRadius = 20;
            butShow.Clicked += ButShow_Clicked;
            
            _stackLayout.Children.Add(groupBox);
            _stackLayout.Children.Add(_frame);
            _stackLayout.Children.Add(butShow);
        }

        private void DatePicker_DateSelected(object sender, DateChangedEventArgs e)
        {
            if (sender == _datePickerFrom) _datePickerTo.MinimumDate = _datePickerFrom.Date.AddDays(1);
            else _datePickerFrom.MaximumDate = _datePickerTo.Date.AddDays(-1);
        }

        private async void ButShow_Clicked(object sender, EventArgs e)
        {
            Record[] records = null;
            RecordDataStorage storage = new RecordDataStorage();
            if (_radioButtonDay.Checked) records = storage.GetForToday();
            else if (_radioButtonLastWeek.Checked) records = storage.GetForPeriod(DateTime.Now.AddDays(-7), DateTime.Now);
            else if (_radioButtonMonth.Checked) records = storage.GetForCurrentMonth();
            else if (_radioButtonPeriod.Checked) records = storage.GetForPeriod(_datePickerFrom.Date, _datePickerTo.Date);
            if (records.Length == 0)
                await DisplayAlert("", Resource.noData, "Ok");
            else await Navigation.PushAsync(new HistoryList(records), true);
        }

        private void RadioButtonPeriod_OnChangeChecked(RadioButton radioButton, bool isChecked)
        {
            if (isChecked) _frame.IsVisible = true;
            else _frame.IsVisible = false;
        }
    }

In version 2.3 _frame appears after click _radioButtonPeriod. But now after update to 2.4 version it does not appear.
What can I do? Really cannot you fix one bug in order to break working code?
Comment 1 Paul DiPietro [MSFT] 2017-10-02 19:32:33 UTC
Please keep comments civil. We provide prereleases in the hopes that any potential regressions might be caught, and in this case there may be one that slipped through. The code provided is missing code not present. A reproduction project with the minimal amount of code required to reproduce the behavior will help us to investigate this further.
Comment 2 Roman 2017-10-02 19:37:41 UTC
How can I help you?
Comment 3 Roman 2017-10-02 20:21:41 UTC
Created attachment 25058 [details]
screenshot

this is view application on 2.3.270 version
Comment 4 Roman 2017-10-02 20:24:20 UTC
Created attachment 25059 [details]
view application

this is view of application on 2.3.270 version in case when last radiobutton checked
Comment 5 Paul DiPietro [MSFT] 2017-10-02 20:58:55 UTC
What was meant was that it appears not all of the necessary code was pasted and it refers to other classes (such as Record or RecordDataStorage). Rather than posting screenshots, putting together a reproduction project that we can run with the minimal amount of code possible necessary to reproduce the reported behavior will help us to investigate further.
Comment 6 Roman 2017-10-03 05:48:35 UTC
You don't need ButShow_Clicked(object sender, EventArgs e) method. It is enough class constructor and RadioButtonPeriod_OnChangeChecked(RadioButton radioButton, bool isChecked) from this code to reproduce. I can only give you GroupBox and RadioButton descriptions. Wait 10 hours and I will give you code. Have a nice mood!
Comment 7 Roman 2017-10-03 18:15:21 UTC
using Android.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Xamarin.Forms;

namespace Controls
{
    public class RadioButton : Grid
    {
        private Image _image;
        private ImageSource _checkedImg, _uncheckedImg;
        private bool _checked;
        private Label _label;
        private object _lockingObject;
        public event Action<RadioButton, bool> OnChangeChecked;

        public RadioButton() : base()
        {
            this.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
            this.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
            this.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(9, GridUnitType.Star) });
            this.Padding = new Thickness(0, 10);
            this.BackgroundColor = Color.Transparent;
            TapGestureRecognizer tapGestureRecognizer = new TapGestureRecognizer();
            tapGestureRecognizer.Tapped += TapGestureRecognizer_Tapped;
            this.GestureRecognizers.Add(tapGestureRecognizer);
            _checkedImg = ImageSource.FromResource("Controls.Images.RadioButton.checked.png");
            _uncheckedImg = ImageSource.FromResource("Controls.Images.RadioButton.unchecked.png");
            _image = new Image();
            _image.Source = _uncheckedImg;
            this.Children.Add(_image, 0, 0);
            this.PropertyChanged += RadioButton_PropertyChanged;
        }

        public bool Checked
        {
            get { return _checked; }
            private set
            {
                _checked = value;
                if (_checked) _image.Source = _checkedImg;
                else _image.Source = _uncheckedImg;
                if (OnChangeChecked != null) OnChangeChecked(this, value);
            }
        }

        public void Check()
        {
            if (Checked != true) Checked = true;
        }

        internal void UnCheck()
        {
            if (Checked != false) Checked = false;
        }

        internal void SetLockingObject(object obj)
        {
            _lockingObject = obj;
        }

        private void RadioButton_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if(e.PropertyName == "BackgroundColor")
            {

            }
        }

        private void TapGestureRecognizer_Tapped(object sender, EventArgs e)
        {
            lock(_lockingObject)
            {
                Check();
            }
        }

        public string Text
        {
            get
            {
                return _label == null ? "" : _label.Text;
            }
            set
            {
                if (_label == null)
                {
                    _label = new Label();
                    _label.VerticalOptions = LayoutOptions.Center;
                    _label.HorizontalOptions = LayoutOptions.Start;
                    this.Children.Add(_label, 1, 0);
                }
                _label.Text = value;
            }
        }
    }
}
Comment 8 Roman 2017-10-03 18:15:55 UTC
using Android.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Xamarin.Forms;

namespace Controls
{
    public class GroupBox:StackLayout
    {
        private object _lockingObject;
        public GroupBox(/*StackOrientation orientation*/)
        {
            // Orientation = orientation;
            Orientation = StackOrientation.Vertical;
            _lockingObject = new object();
        }

        protected override void OnChildAdded(Element child)
        {
            if(child is RadioButton)
            {
                RadioButton radioButton = child as RadioButton;
                radioButton.SetLockingObject(_lockingObject);
                radioButton.OnChangeChecked += RadioButton_OnChangeChecked;
            }
                
            base.OnChildAdded(child);
        }

        private void RadioButton_OnChangeChecked(RadioButton radioButton, bool isChecked)
        {
            if(isChecked)
            {
                foreach(View view in Children)
                {
                    if (view != radioButton && view is RadioButton) (view as RadioButton).UnCheck();
                }
            }
        }
    }
}
Comment 9 Roman 2017-10-03 18:16:59 UTC
How can I join to Xamarin developing team?
Comment 10 Paul DiPietro [MSFT] 2018-01-03 20:15:35 UTC
As we never received a full reproduction project (not pasted code nor individual files but a complete, zipped solution), this will be closed. Please open a new issue on GitHub at https://github.com/xamarin/Xamarin.Forms/issues if the issue still occurs on the latest 2.5.0 stable release.
Comment 11 Roman 2018-01-13 01:31:34 UTC
I've checked. All right with this issue but it happened new problem