How can I highlight / draw a visual object in WPF?

If I had a canvas with n number of visual objects of any shape or size, how would I select / outline a visual object programmatically?

Is there something built into WPF to help me?

+5
source share
3 answers

After reading the comments in another answer in which you state that you want the outline to fit the shape of the visual image, I can suggest you take a look at BitmapEffects. There is one effect of Outer Glow.

Duplication of visual effects is likely to be less effective and likely to lead to a lot of complications due to other aspects of these elements, such as any bindings.

: .NET 4.0 BitmapEffects BitmapEffect . . System.Windows.Media.Effects.Effect , , Visual.VisualEffect.

+5

BitmapEffects.

, .NET 3.5 SP1, GPU . , UIElement.BitmapEffect UIElement.Effect..NET 3.5 SP1 : BlurEffect DropShadowEffect. ... ShaderEffect.

Greg Schechter series .

, ( - , ShadowDepth 0, ):

<Path
    x:Name="mouseOverEffect"
    Width="80"
    Height="43.916"
    Stretch="None"
    Fill="#FFFFFFFF"
    Opacity="0"
>
    <Path.Data>
        <PathGeometry FillRule="Nonzero">
            <PathFigure IsClosed="True" StartPoint="39.9592899612151,25.9913931634531">
                <LineSegment Point="80.0000001464848,43.9159987905149"/>
                <LineSegment Point="39.9513899394755,4.97379893856246E-14"/>
                <LineSegment Point="1.77635636294422E-15,43.9159987905149"/>
                <LineSegment Point="39.9592899612151,25.9913931634531"/>
            </PathFigure>
        </PathGeometry>
    </Path.Data>
    <Path.Effect>
        <DropShadowEffect
            Color="#FFFFFFFF"
            BlurRadius="10"
            ShadowDepth="0"
        />
    </Path.Effect>
</Path> 
+5

If you wrap these visual objects in Border ... and make Opacity 0 by default ... then you could programmatically turn Opacity into 1 when you need to.

Does it help?

+1
source

All Articles