Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Create border/Square with hollow center.

$
0
0

Hi,

I want to create a control in WPF/Silverlight. This control is rectangle/border which is hollow from the center. My intention is to grayed out everything else except for a squared area within the rectangle/border container.

Also, I want that hollow part to be able to move based on mouse movement. I've created a sample application.  I have used the following code to achieve this: 

<Grid><Image x:Name="_image" Source="pack://siteoforigin:,,,/sample_10.jpg" Stretch="Fill" /><Path x:Name="mask" Fill="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}" Opacity="0.895" MouseMove="Path_MouseMove_1" ><Path.Data><CombinedGeometry GeometryCombineMode="Exclude"><CombinedGeometry.Geometry1><RectangleGeometry RadiusX="5" RadiusY="5" Rect="0,0,517,319" /></CombinedGeometry.Geometry1><CombinedGeometry.Geometry2><RectangleGeometry RadiusX="5" RadiusY="5" Rect="{Binding RectProperty}" /></CombinedGeometry.Geometry2></CombinedGeometry></Path.Data></Path></Grid>

Outpur for above will look like this: 

Now the problem is that when I try to move mouse some time application hangs. I hope it may because for each mouse movement I am inserting a new "Rect" to change it's location. 

Is there any alternate solution to achieve this or to make movement smooth. 

Thanks everyone for help in advance. 


Blog, , Twitter - My Apps - Mark post as answer if you find this post as a solution, to help others.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



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