Area Selection of a gird

Page 1 of 1

0 Replies - 8826 Views - Last Post: 10 February 2013 - 06:40 PM Rate Topic: -----

#1 killingseed  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 12-July 11

Area Selection of a gird

Posted 10 February 2013 - 06:40 PM

working with some grid with 4 , 8 or 16 rows and up to 4000 columns like a timeline.
first time messing with WPF. i have most of what i am looking to do doing what it needs to do. getting down to some of the
finals steps and hitting some snags.

i have a grid with two elements with in it , a canvas and

i am using ....
<Grid MouseDown="Grid_MouseDown" 
          MouseUp="Grid_MouseUp"
          MouseMove="Grid_MouseMove"
        x:Name="MainGridArea" Background="Transparent">
        <Canvas>
            <Grid  
                   
                   Name="TimeLineGrid" Width="400" Background="LightSteelBlue" ShowGridLines="True">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="45" />
                    <RowDefinition Height="45" />
                    <RowDefinition Height="45" />
                </Grid.RowDefinitions>

            

            </Grid>
        </Canvas>

        <Canvas Margin="0,0,0,-94">
            <!-- This canvas is overlaid over the previous canvas and is used to 
                place the rectangle that implements the drag selection box. -->
            <Rectangle
                x:Name="selectionBox"
                Visibility="Collapsed"
                Stroke="Black"
                StrokeThickness="1"
                />
            <TextBox Canvas.Left="6" Canvas.Top="177" Height="279" Name="textBox1" Width="454" />
        </Canvas>
    </Grid>



with mouse down i can return the element of the the grid and can use the same code in mouseup and so i know the start of the area select and the end of the area select and able to change all elements with in the selected grid area.


 var element = (UIElement)e.Source;
            c = Grid.GetColumn(element);
            r = Grid.GetRow(element);




how ever when i trigger CaptureMouse , ReleaseMouseCapture to have a area select rectangle

 private void Grid_MouseUp(object sender, MouseButtonEventArgs e)
{
Grid.CaptureMouse(); 
}

Grid.ReleaseMouseCapture();




Is This A Good Question/Topic? 0
  • +

Page 1 of 1