我得到了一个控件,它看起来像这样,它有几个文本框
[1 ][2 ][3 ][4 ]
现在在我的应用程序中这些控件形成了一个类似于
的矩阵[1 ][2 ][3 ][4 ]
[1 ][2 ][3 ][4 ]
[1 ][2 ][3 ][4 ]
现在我想设置1 3和4 IsTabStop = false
,这样用户可以通过第二个文本框选项卡。做完这些之后,我发现我现在无法集中注意力了。令我惊讶的是,在WPF中这不是真的,所以这只是Silverlight的另一个意想不到的限制!
http://msdn.microsoft.com/ru-ru/library/system.windows.controls.control.istabstop (v = vs.95) . aspx
如何通过[2 ]
计划进行我的初始选项卡?
我相信你可以扩展TextBox控件使其可对焦。请看这篇文章
附加属性
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
<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"/>
你可以把它附加到任何从Control继承的元素