示例#1
0
        private void MiniUtilsRadioButton_OnClick(object sender, RoutedEventArgs e)
        {
            UtilTypeListBox.SelectedValue = null;

            var yOffset = MiniUtilsGrid.TranslatePoint(new Point(), AllUtilScrollViewer).Y;

            AllUtilScrollViewer.ScrollToVerticalOffset(AllUtilScrollViewer.VerticalOffset + yOffset - 2);

            // AllUtilScrollViewer.ScrollToBottom();
        }
示例#2
0
        private void UtilTypeListBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (MiniUtilsRadioButton == null ||
                !(UtilTypeListBox.SelectedValue is UtilType) ||
                VisualTreeHelper.HitTest(UtilTypeListBox, Mouse.GetPosition(UtilTypeListBox)) == null)
            {
                return;
            }

            var source = AllUtilsItemsControl.ItemsSource as IEnumerable <ClassifiedUtil>;
            var util   = source.FirstOrDefault(u => u.Type == (UtilType)UtilTypeListBox.SelectedValue);

            if (source == null || util == null)
            {
                return;
            }

            MiniUtilsRadioButton.IsChecked = false;

            var selectedIndex = util.Index;

            if (selectedIndex == 0)
            {
                AllUtilScrollViewer.ScrollToTop();
            }
            else
            {
                var item = AllUtilsItemsControl.ItemContainerGenerator.ContainerFromIndex(selectedIndex) as FrameworkElement;
                if (item == null)
                {
                    return;
                }

                var yOffset = item.TranslatePoint(new Point(), AllUtilScrollViewer).Y;

                AllUtilScrollViewer.ScrollToVerticalOffset(AllUtilScrollViewer.VerticalOffset + yOffset - 2);
            }
        }