NumericUpDown 컨트롤 (WPF 확장 툴킷 버전 2.9부터)을 사용하고 있으며 연결된 속성을 통해 포커스를 설정하려고합니다.NumericUpDown - 포커스가 설정되지 않았습니다.
내 XAML 여기
<xctk:DecimalUpDown FormatString="F5"
wbui:FocusExtension.IsFocused="{Binding Path=IsFocusedMenge, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
Value="{Binding Path=Menge, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
/>
내 FocusExtensiion.IsFocues
private static void IsFocusedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var fe = (FrameworkElement)d;
if (e.OldValue == null)
{
fe.GotFocus += FrameworkElement_GotFocus;
fe.LostFocus += FrameworkElement_LostFocus;
}
if (!fe.IsVisible)
{
fe.IsVisibleChanged += new DependencyPropertyChangedEventHandler(FrameworkElement_IsVisibleChanged);
}
if ((bool)e.NewValue)
{
fe.Focus(); // will be called
}
}
내가 참으로 나의 재산 IsFocusedMenge를 설정 한 다음 초점이 설정되지 않습니다. 코드 줄 fe.Focus() 내가 거기에 중단 점을 설정할 때 호출됩니다.
다른 주제가 여기에 있는데 (How to set focus on NumericUpDown control?),이 속성을 Focusable = true로 설정하면 fe.Focus() 메서드를 호출 할 때 StackOverFlowException이 발생합니다.
아이디어가 있으십니까? 고마워.
업데이트는보기/UserControl을에 포커스를 설정하기 위해 그리드에 이벤트를 추가로 시도 ...하지만 성공하지.
private void GridMenge_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if ((bool)e.NewValue)
{
this.Menge.Focus();
}
}
초점이 아직 설정되지 않은 (속성 Focusable이이 True/False로 설정 - 아무 변화 없음)