Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Area Selection of a gird

$
0
0
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">
            &lt!-- 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();



Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>