Setting Focus on FrameworkElements in Canvas creates Border - how to disable?
-
14 April 2012 21:25
Hello,
I'm visualizing a graph with a canvas where I place vertex and edge controls.To show how algorithmen are working I set the active vertex/edge as active by calling the setFocus method.
public virtual void setFocus(Edge v) { if (getVertexVisualization(v) != null) Canvas.Children.OfType<EdgeVisualization>().Where(a => a.Edge.Equals(v)).FirstOrDefault<EdgeVisualization>().Focus(); }With a Style/Trigger I increase the Border thickness. When a control on the Canvas gets the Focus() there will appear a dotted border around the control.
How can I make this dotted boarder disapear? The border doesnt look very nice.
Best regards
martin
- Diedit oleh martin.doku 14 April 2012 21:32
Semua Balasan
-
16 April 2012 0:26
Hi,
What is the EdgeVisualization type, custom control, user control or re-styled button?
Regards
-
16 April 2012 1:31Try setting IsFocusable to false.
-
16 April 2012 10:41
Hi,
What is the EdgeVisualization type, custom control, user control or re-styled button?
Regards
Its a Custom UserControl. It looks something like that:
<Style TargetType="{x:Type local:EdgeVisualization}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type local:EdgeVisualization}"> <Line Stroke="{TemplateBinding Foreground}" StrokeThickness="{TemplateBinding StrokeThickness}" X1="{Binding Mode=TwoWay,Path=PositionU.X,UpdateSourceTrigger=PropertyChanged,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:EdgeVisualization}}}" Y1="{Binding Mode=TwoWay,Path=PositionU.Y,UpdateSourceTrigger=PropertyChanged,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:EdgeVisualization}}}" X2="{Binding Mode=TwoWay,Path=PositionV.X,UpdateSourceTrigger=PropertyChanged,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:EdgeVisualization}}}" Y2="{Binding Mode=TwoWay,Path=PositionV.Y,UpdateSourceTrigger=PropertyChanged,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:EdgeVisualization}}}" />VertexVisualization:
<Style TargetType="{x:Type local:VertexVisualization}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type local:VertexVisualization}"> <Border x:Name="PART_Border" CornerRadius="50" Background="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}"> <TextBlock Text="{Binding Mode=TwoWay,Path=Vertex.Weighted,UpdateSourceTrigger=PropertyChanged,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type local:VertexVisualization}}}" HorizontalAlignment="Center" VerticalAlignment="Center" /> </Border> </ControlTemplate>
- Diedit oleh martin.doku 16 April 2012 10:44
-
16 April 2012 10:42
Try setting IsFocusable to false.
I need to set Focus on the elements. The Edge/Vertex-Visualization has a Trigger on IsFocused to show the user which element is currently processed by the algorithm.- Diedit oleh martin.doku 16 April 2012 11:10 _
-
16 April 2012 14:50
Try setting focusvisualstyle to null on your usercontrol.
<MyControl FocusVisualStyle="{x:Null}" />
- Ditandai sebagai Jawaban oleh martin.doku 16 April 2012 14:58