Area Selection of a gird

Page 1 of 1

1 Replies - 9794 Views - Last Post: 10 February 2013 - 07:02 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:56 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);




however, when i trigger CaptureMouse, ReleaseMouseCapture to have the area select rectangle visible the mouseup function for reporting grid UIElement no longer the correct element in order to report the grids clicked loction of C, R.


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




thoughts are that the elements focus is changing and not returning back to the element that needs to report the column and row location of the gird.

Is This A Good Question/Topic? 0
  • +

Replies To: Area Selection of a gird

#2 killingseed  Icon User is offline

  • New D.I.C Head

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

Re: Area Selection of a gird

Posted 10 February 2013 - 07:02 PM

odd sorry about the duplicate post not sure what happen there. spent more the 17 min working this post, as i was doing other things as well, and clicked only once for post. someone can delete those duplicates thanks.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1