已经实现鼠标按住左键不放 进行拖拽选定.
问:如何设置选定控件的背景色为红色代码 <Grid Name="grid1" Margin="47,190,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Height="286" Width="777" MouseLeftButtonDown="grid1_MouseLeftButtonDown" MouseLeftButtonUp="grid1_MouseLeftButtonUp" MouseMove="grid1_MouseMove">
            <Grid.RowDefinitions>
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid Name="gridContainer1"  HorizontalAlignment="Left" VerticalAlignment="Top" Height="286" Width="777" MouseLeftButtonDown="grid1_MouseLeftButtonDown">
            </Grid>
        </Grid>     Line oneTotwo;
        Line oneTothree;
        Line twoTofour;
        Line threeTofour;        int clicktimes = 0;  
        private void grid1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            int x = Convert.ToInt32(e.GetPosition(grid1).X);
            int y = Convert.ToInt32(e.GetPosition(grid1).Y);            label2333.Content = "x:" + x + "  y:" + y;
            if (clicktimes > 0)
            {
                for (int i = 0; i < 4; i++)
                {
                    grid1.Children.RemoveAt(0);
                }
                clicktimes = 0;
            }
            if (0 == clicktimes)
            {                Point clickPoint = (Point)e.GetPosition(grid1);
           
                oneTotwo = new Line();
                oneTotwo.Stroke = Brushes.Red;
                oneTotwo.Fill = Brushes.Red;
                oneTotwo.StrokeLineJoin = PenLineJoin.Bevel;
                oneTotwo.X1 = clickPoint.X;
                oneTotwo.Y1 = clickPoint.Y;
                oneTotwo.X2 = clickPoint.X + 10;
                oneTotwo.Y2 = clickPoint.Y;
                oneTotwo.StrokeThickness = 1;
                grid1.Children.Insert(0,oneTotwo);
                int zindex = grid1.Children.Count;
                Grid.SetZIndex(oneTotwo, zindex);                oneTothree = new Line();
                oneTothree.Stroke = Brushes.Red;
                oneTothree.Fill = Brushes.Red;
                oneTothree.StrokeLineJoin = PenLineJoin.Bevel;
                oneTothree.X1 = clickPoint.X;
                oneTothree.Y1 = clickPoint.Y;
                oneTothree.X2 = clickPoint.X;
                oneTothree.Y2 = clickPoint.Y + 10;
                oneTothree.StrokeThickness = 1;
                grid1.Children.Insert(1,oneTothree);
                zindex = grid1.Children.Count;
                Grid.SetZIndex(oneTothree, zindex);                twoTofour = new Line();
                twoTofour.Stroke = Brushes.Red;
                twoTofour.Fill = Brushes.Red;
                twoTofour.StrokeLineJoin = PenLineJoin.Bevel;
                twoTofour.X1 = clickPoint.X + 10;
                twoTofour.Y1 = clickPoint.Y;
                twoTofour.X2 = clickPoint.X + 10;
                twoTofour.Y2 = clickPoint.Y + 10;
                twoTofour.StrokeThickness = 1;
                grid1.Children.Insert(2, twoTofour);
                zindex = grid1.Children.Count;
                Grid.SetZIndex(twoTofour, zindex);                threeTofour = new Line();
                threeTofour.Stroke = Brushes.Red;
                threeTofour.Fill = Brushes.Red;
                threeTofour.StrokeLineJoin = PenLineJoin.Bevel;
                threeTofour.X1 = clickPoint.X;
                threeTofour.Y1 = clickPoint.Y + 10;
                threeTofour.X2 = clickPoint.X + 10;
                threeTofour.Y2 = clickPoint.Y + 10;
                threeTofour.StrokeThickness = 1;
                grid1.Children.Insert(3, threeTofour);
                zindex = grid1.Children.Count;
                Grid.SetZIndex(threeTofour, zindex);
                clicktimes++;
            }        }        private void grid1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            int x = Convert.ToInt32(e.GetPosition(grid1).X);
            int y = Convert.ToInt32(e.GetPosition(grid1).Y);
            label2333.Content = "离开位置: " + Convert.ToString(x) + "," + Convert.ToString(y);
            oneTotwo = null;
            oneTothree = null;
            twoTofour = null;
            threeTofour = null;
            
            //获取已选定的表格
           object item = e.GetPosition(gridContainer1);            //gridContainer1.RowDefinitions[0].
        }
        private void grid1_MouseMove(object sender, MouseEventArgs e)
        {
             Point drawPoint = (Point)e.GetPosition(grid1);  
            if (oneTotwo != null & twoTofour != null & oneTothree != null & threeTofour != null & e.LeftButton == MouseButtonState.Pressed)  
            {  
                twoTofour.X1 = oneTotwo.X2 = twoTofour.X2 = threeTofour.X2 = drawPoint.X;  
                threeTofour.Y1 = threeTofour.Y2 = twoTofour.Y2 = twoTofour.Y2 = oneTothree.Y2 = drawPoint.Y;  
            }  
        }WPF控件