예제 #1
0
        private void ListBoxPoints_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //Get Selected Item
            MapInfo MyItem = (MapInfo)ListBoxPoints.SelectedItem;

            if (MyItem == null)
                return;

            //Change Color Last Item
            if (SelectedItem != null)
            {
                SelectedItem.EllipsePoint.Fill = new SolidColorBrush(Colors.Red);
                SelectedItem.EllipsePoint.Stroke = new SolidColorBrush(Colors.Red);
            }

            //Change selected Item Color
            MyItem.EllipsePoint.Fill = new SolidColorBrush(Colors.Aqua);
            MyItem.EllipsePoint.Stroke = new SolidColorBrush(Colors.Aqua);

            SelectedItem = MyItem;
        }
예제 #2
0
        private void CreateMapPoint(int X, int Y)
        {
            MapInfo NewPoint = new MapInfo(X, Y, 10, "new Info");

            MapPoints.Add(NewPoint);

            //Add Point to Canvas
            GridImg.Children.Add(NewPoint.EllipsePoint);
            GridImg.Children.Add(NewPoint.LabelPoint);

            ListBoxPoints.Items.Refresh();

            // Get the border of the listview (first child of a listview)
            Decorator border = VisualTreeHelper.GetChild(ListBoxPoints, 0) as Decorator;
            if (border != null)
            {
                // Get scrollviewer
                ScrollViewer scrollViewer = border.Child as ScrollViewer;
                if (scrollViewer != null)
                {
                    // End of the Scroll
                    scrollViewer.ScrollToVerticalOffset(scrollViewer.ExtentHeight);
                }
            }
        }