> public void DrawHoles() > { > // Iterate over each HolePattern in the HolePatterns collection... > foreach (HolePattern HolePattern in HolePatterns) > { > // Now iterate over each Hole in the HoleList of the current HolePattern... > foreach (Hole Hole in HolePattern.HoleList) > { > Hole.CanvasX = SketchX0 + (Hole.AbsX * _ZoomScale); > Hole.CanvasY = SketchY0 - (Hole.AbsY * _ZoomScale); > Hole.HoleEntity.Style = (Style)this.FindResource("EllipseStyle"); <---- Had to learn this part!!! > canvas1.Children.Add(Hole.HoleEntity); > } > } > } >>
<Window x:Class="WpfApplication1.Window17" >> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >> Title="Window17" Height="300" Width="300"> >> <Window.Resources> >> <Style TargetType="Ellipse" x:Key="xxx"> >> <Setter Property="Stroke" Value="Black"/> >> <Setter Property="StrokeThickness" Value="1" /> >> <Style.Triggers> >> <Trigger Property="IsMouseOver" Value="true" > >> <Setter Property="Fill" Value="Yellow"/> >> <Setter Property="StrokeThickness" Value="5" /> >> <Setter Property="Stroke" Value="Red" /> >> </Trigger> >> </Style.Triggers> >> </Style> >> </Window.Resources> >> <Canvas> >> <Ellipse Style="{StaticResource xxx}" Canvas.Top="10" Canvas.Left="10" Width="40" Height="40" > >> </Ellipse> >> </Canvas> >></Window> >>You still have to sneak up on it a bit but it will be obvious when the mousedown will target the item in question - and because you have a temporary fill anywhere within the bounds will count as a hit...