###前提・実現したいこと
現在TextBoxを継承したコントロールを作成しているのですが、作った
コントロールに対してTabキーでフォーカス移動すると、何故かフォーカスが
作ったコントロールの外側に当たり、次にもう一回押すとテキストボックスの内部に
フォーカスが当たる(文字が打てる状態)という風に2回フォーカスの判定があるような
状態になっています。
これを内部にフォーカスが当たる1回だけに直したいです。
###該当のソースコード
C#
1using System; 2using System.Collections.Generic; 3using System.ComponentModel; 4using System.Linq; 5using System.Text; 6using System.Threading.Tasks; 7using System.Windows; 8using System.Windows.Controls; 9using System.Windows.Data; 10using System.Windows.Documents; 11using System.Windows.Input; 12using System.Windows.Media; 13using System.Windows.Media.Imaging; 14using System.Windows.Navigation; 15using System.Windows.Shapes; 16 17namespace WpfCustomControlLibrary2 18{ 19 public class CustomControl1 : TextBox 20 { 21 static CustomControl1() 22 { 23 DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomControl1), new FrameworkPropertyMetadat a(typeof(CustomControl1))); 24 } 25} 26 27XAML 28<ResourceDictionary 29 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 30 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 31 xmlns:local="clr-namespace:WpfCustomControlLibrary2"> 32 33 <Style TargetType="{x:Type local:CustomControl1}"> 34 <Setter Property="Template"> 35 <Setter.Value> 36 <ControlTemplate TargetType="{x:Type local:CustomControl1}"> 37 <TextBox x:Name="Textbox" Height="{TemplateBinding Height}" 38 Width="{TemplateBinding Width}" 39 Text="{TemplateBinding Text}" 40 /> 41 </Border> 42 </ControlTemplate> 43 </Setter.Value> 44 </Setter> 45 </Style> 46</ResourceDictionary> 47 48
###試したこと
上記のソースを実際にビルドしコントロールを使用してみると
Tabキーを押した際に2回フォーカスの判定が出てしまいます。
###補足情報(言語/FW/ツール等のバージョンなど)
環境はVisualStudio2013proでWPFカスタムコントロールライブラリから作成しております。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。