나는 listview가 있습니다. 다음과 같이 int를 설정했습니다. -listview의 텍스트 상자 - 소스 업데이트 및 탭에서 포커스 이동이 동시에 작동하지 않습니다.
<ListView KeyboardNavigation.TabNavigation="Local" SelectionMode="Extended">
<ListView.ItemContainerStyle>
<Style>
<Setter Property="KeyboardNavigation.IsTabStop" Value="False"/>
</Style>
</ListView.ItemContainerStyle>
listview의 한 열에 TextBox가 있습니다.
내 텍스트 상자에 UpdateSourceTrigger = LostFocus 을 설정하면 목록보기를 통해 탭을 만들 수 없습니다 ... 대신 UpdateSourceTrigger = Explicit를 설정하면 탭이 작동하지만 소스가 업데이트되지 않습니다.
날편집 아래
public class TextBoxBehavior
{
#region Attached Property EscapeClearsText
public static readonly DependencyProperty EscapeClearsTextProperty
= DependencyProperty.RegisterAttached("EscapeClearsText", typeof(bool), typeof(TextBoxBehavior),
new FrameworkPropertyMetadata(false, new PropertyChangedCallback(OnEscapeClearsTextChanged)));
private static void OnEscapeClearsTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if ((bool)e.NewValue)
{
var textBox = d as TextBox;
if (textBox != null)
{
textBox.KeyUp -= TextBoxKeyUp;
textBox.KeyUp += TextBoxKeyUp;
}
}
}
private static void TextBoxKeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
{
//((DataContext<string>)((TextBox)sender).GetBindingExpression(TextBox.TextProperty).DataItem).RollbackChanges();
((TextBox)sender).Text = string.Empty;
}
else if (e.Key == Key.Enter)
{
((TextBox)sender).GetBindingExpression(TextBox.TextProperty).UpdateSource();
}
}
public static void SetEscapeClearsText(DependencyObject dependencyObject, bool escapeClearsText)
{
if (!ReferenceEquals(null, dependencyObject))
dependencyObject.SetValue(EscapeClearsTextProperty, escapeClearsText);
}
public static bool GetEscapeClearsText(DependencyObject dependencyObject)
{
if (!ReferenceEquals(null, dependencyObject))
return (bool)dependencyObject.GetValue(EscapeClearsTextProperty);
return false;
}
#endregion Attached Property EscapeClearsText
}
거기에 연결된 속성이있는 목록보기/gridview에 열이 도와주세요. 당신이 명시 적으로 UpdateSourceTrigger을 설정하면
<GridViewColumn Width="60">
<GridViewColumnHeader Content="Priority"
Command="{Binding Path=SortSelectedClaimCodeGroupsCommand}"
CommandParameter="Item.IntPriority">
</GridViewColumnHeader>
<GridViewColumn.CellTemplate>
<DataTemplate>
<Border DataContext="{Binding Item.Priority}"
Style="{StaticResource ValidationResultBorderStyle}" HorizontalAlignment="Left" >
<TextBox Width="200" MaxLength="25" Text="{Binding Path=Value,Mode=TwoWay,
UpdateSourceTrigger=Explicit}" local:TextBoxBehavior.EscapeClearsText="True" >
입력으로 "Enter 키"를 취할 첨부 된 속성을 사용하고 있습니다. – Relativity
먼저 UpdateSourceTrigger가 UI 탭에 영향을 주어서는 안됩니다. 둘째, 소스를 업데이트하려고 할 때? Enter 키를 누르는 경우, 거기에 중단 점을 넣어서 연결된 속성에 대한 코드가 호출되는지 확인 했습니까? 여기에 코드를 붙이면 도움이 될 것입니다. –
코드를 추가했습니다. 그리고 컨트롤에 중단 점을 넣음으로써 컨트롤이 왔는지 확인했습니다. – Relativity