I want to have a rubberband on a silverlight image control, in order to select zones on an image and copy it.
Thanks for your help.
(No specific version of SL required)
Guys??? Where are the experts? any ideas? remarks, anything....????开发者_开发百科
The trick to add a rubber band is to create a dynamic rectangle on your image control when a mouse click occurs such as:
private void cMain_MouseLeftButtonDown( object sender, MouseButtonEventArgs e )
{
OriginatingPostionOnCanvas = e.GetPosition( cMain );
RubberBandBox = new Rectangle() { Width = 1,
Height = 1,
Fill = new SolidColorBrush( Colors.Red ),
Opacity = .1 };
RubberBandBox.SetValue( Canvas.LeftProperty, OriginatingPostionOnCanvas.X);
RubberBandBox.SetValue( Canvas.TopProperty, OriginatingPostionOnCanvas.Y );
cMain.Children.Add( RubberBandBox );
}
Then one handles the mouse movements and resizes the rectangle as appropriate. I provide more detail about a process with a canvas on my blog entitled Silverlight (How To): Manipulation of Dynamic Selection Rubber Band in C#
精彩评论