TextBox 컨트롤을 확장하여 포커스를 가질 수 있다고 생각합니다. this post을 참조하십시오.
public class Ex
{
public static bool GetIsTabStop(DependencyObject obj)
{
return (bool)obj.GetValue(IsTabStopProperty);
}
public static void SetIsTabStop(DependencyObject obj, bool value)
{
obj.SetValue(IsTabStopProperty, value);
}
// Using a DependencyProperty as the backing store for IsTabStop. This enables animation, styling, binding, etc...
public static readonly DependencyProperty IsTabStopProperty =
DependencyProperty.RegisterAttached("IsTabStop", typeof(bool), typeof(Ex), new PropertyMetadata(true, Callback));
private static void Callback(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var control = d as Control;
if (control != null)
{
control.IsTabStop = (bool)e.NewValue;
control.MouseLeftButtonDown += (sender, args) =>
{
if (!control.IsTabStop)
{
control.IsTabStop = true;
control.Focus();
control.IsTabStop = false;
}
};
}
}
}
재산권
첨부
XAML 당신은 기본적으로 Control에서 상속 된 것 무엇이든이를 첨부 할 수 있습니다
<TextBox HorizontalAlignment="Left" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Margin="215,49,0,0" RenderTransformOrigin="0,7.25"/>
<TextBox HorizontalAlignment="Left" local:Ex.IsTabStop="False" TextWrapping="Wrap" Text="TextBox" Margin="215,96,0,0" VerticalAlignment="Top"/>
<RadioButton Content="RadioButton" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="210,144,0,0"/>
<RadioButton Content="RadioButton" local:Ex.IsTabStop="False" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="213,183,0,0"/>
.
gahh thats hackish. 나는 radiobuttons가 너무, 더 해킹 inc .. 그 +1에 연결된 덕분에 +1 –
이 경우 연결 속성은 친구입니다. pls 내 업데이트 된 답변을 참조하십시오. –
덕분에이 기능이 훨씬 향상되었으며이 문제를 해결할 수있는 더 나은 방법 중 하나라고 생각합니다. –