Skip to content

Instantly share code, notes, and snippets.

@yoshikazuendo
Created August 25, 2016 03:03
Show Gist options
  • Save yoshikazuendo/1c4765d6ea0a50ede6887af8c17603ae to your computer and use it in GitHub Desktop.
Save yoshikazuendo/1c4765d6ea0a50ede6887af8c17603ae to your computer and use it in GitHub Desktop.
【WPF】コントロールのフォーカスのStyleとFocusVisualStyle
<!-- MSDN -->
<!-- https://msdn.microsoft.com/ja-jp/library/bb613567(v=vs.100).aspx -->
<!-- こちらも凄く参考になります。 -->
<!-- http://grabacr.net/archives/464 -->
<!-- フォーカス時の見た目を消す-->
<TextBox Text="aikazuyendo"
FocusVisualStyle="{x:Null}" />
<!-- Styleでの設定も可能なので、独自のFocusVisualStyleを作成できる。-->
<Application x:Class="WpfApplication1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<Style x:Key="{x:Static SystemParameters.FocusVisualStyleKey}">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle StrokeThickness="1"
Stroke="Red"
StrokeDashArray="3 1"
SnapsToDevicePixels="true" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Application.Resources>
</Application>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment