コード例 #1
0
        private void OnRepeaterElementPrepared(ItemsRepeater sender, ItemsRepeaterElementPreparedEventArgs args)
        {
            var element = args.Element;

            if (element != null)
            {
                var toggleButton = element as ToggleButton;
                if (toggleButton != null)
                {
                    toggleButton.Checked   += OnChildChecked;
                    toggleButton.Unchecked += OnChildUnchecked;

                    // If the developer adds a checked toggle button to the collection, update selection to this item.
                    if (SharedHelpers.IsTrue(toggleButton.IsChecked))
                    {
                        Select(args.Index);
                    }
                }
                var repeater = m_repeater;
                if (repeater != null)
                {
                    var itemSourceView = repeater.ItemsSourceView;
                    if (itemSourceView != null)
                    {
                        element.SetValue(AutomationProperties.PositionInSetProperty, args.Index + 1);
                        element.SetValue(AutomationProperties.SizeOfSetProperty, itemSourceView.Count);
                    }
                }
            }
        }
コード例 #2
0
ファイル: RadioButtons.cs プロジェクト: Robert-Louis/Uno
        private void OnRepeaterElementIndexChanged(ItemsRepeater sender, ItemsRepeaterElementIndexChangedEventArgs args)
        {
            var element = args.Element;

            if (element != null)
            {
                element.SetValue(AutomationProperties.PositionInSetProperty, args.NewIndex + 1);

                // When the selected item's index changes, update selection to match
                var elementAsToggle = element as ToggleButton;
                if (elementAsToggle != null)
                {
                    if (SharedHelpers.IsTrue(elementAsToggle.IsChecked))
                    {
                        Select(args.NewIndex);
                    }
                }
            }
        }
コード例 #3
0
ファイル: RadioButtons.cs プロジェクト: Robert-Louis/Uno
        private void OnRepeaterElementClearing(ItemsRepeater itemsRepeater, ItemsRepeaterElementClearingEventArgs args)
        {
            var element = args.Element;

            if (element != null)
            {
                // If the removed element was the selected one, update selection to -1
                var elementAsToggle = element as ToggleButton;
                if (elementAsToggle != null)
                {
                    // Revoke
                    elementAsToggle.Checked   -= OnChildChecked;
                    elementAsToggle.Unchecked -= OnChildUnchecked;

                    if (SharedHelpers.IsTrue(elementAsToggle.IsChecked))
                    {
                        Select(-1);
                    }
                }
            }
        }
コード例 #4
0
ファイル: RadioButtons.cs プロジェクト: Robert-Louis/Uno
        private void OnRepeaterElementPrepared(ItemsRepeater sender, ItemsRepeaterElementPreparedEventArgs args)
        {
            var element = args.Element;

            if (element != null)
            {
                var toggleButton = element as ToggleButton;
                if (toggleButton != null)
                {
                    toggleButton.Checked   += OnChildChecked;
                    toggleButton.Unchecked += OnChildUnchecked;

                    // If the developer adds a checked toggle button to the collection, update selection to this item.
                    if (SharedHelpers.IsTrue(toggleButton.IsChecked))
                    {
                        Select(args.Index);
                    }

                    // TODO: Uno specific - remove when #4689 is fixed
                    //If SelectedItem/SelectedIndex has already been set by the time the elements are loaded, ensure we sync the selection
                    if (args.Index == SelectedIndex)
                    {
                        toggleButton.IsChecked = true;
                    }
                }
                var repeater = m_repeater;
                if (repeater != null)
                {
                    var itemSourceView = repeater.ItemsSourceView;
                    if (itemSourceView != null)
                    {
                        element.SetValue(AutomationProperties.PositionInSetProperty, args.Index + 1);
                        element.SetValue(AutomationProperties.SizeOfSetProperty, itemSourceView.Count);
                    }
                }
            }
        }