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); } } } }
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); } } } }