INotifyPropertyChanged
을 구현하는 ContentDialog
이 있습니다. 문자의 x:Bind
구문을 통해 내 코드 숨김의 문자열 속성에 바인딩 된 Text 속성을 가진 TextBox
이 있습니다.ContentDialog 및 x와 관련된 문제 : Bind
나는 TextBox
의 내용을 편집 한 다음 ContentDialog
합니다 (TextBox
에 손실 초점)에서 다른 컨트롤을 클릭 한 다음 나는 차 버튼 클릭 이벤트 처리기에 도착하는 시간에 의해, 기본 버튼을 클릭하면 텍스트 속성이 TextBox
control = PERFECT의 내용으로 업데이트되었습니다.
그러나 TextBox
의 내용을 변경했지만 초점을 유지 한 채 기본 단추를 클릭하면 바인딩이 업데이트되지 않습니다.
이것에 대한 이유는 것 같다 때문에 내장 ContentDialog
의 버튼들이 클릭 eventhandlers이 발사되기 전에 초점을 취득하지 않으며, x:Bind
만 바인딩 LostFocus
을 지원하는, 이러한 바인딩이 업데이트되지 않습니다.
나는이 큰 버그가 존재한다는 것을 비웃었습니다. 그래서 내 2 개 질문
1) 해결
2) 나는 내가 바인딩 자체 내에서 UpdateSourceTrigger
을 변경할 수있는, WPF 스타일을 Binding
구문을 x:Bind
을 포기하고 사용해야합니까가 있습니다.
내가 다른 UWP dev에이 건너와
편집
주위에 작업을 알고 것을 바라고 있어요 필자는이 문제를 설명하는 몇 가지 예제 코드를 만들었습니다.
페이지 :
<Page
x:Class="App1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Button Content="Open" Click="OpenClick" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</Page>
코드 숨김
public sealed partial class MainPage : Page
{
public MainPage()
{
InitializeComponent();
}
private async void OpenClick(object sender, RoutedEventArgs e)
{
var dialog = new ContentDialog1();
await dialog.ShowAsync();
}
}
내용의 대화 : 뒤에
<ContentDialog
x:Class="App1.ContentDialog1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Title="TITLE"
PrimaryButtonText="Button1"
PrimaryButtonClick="ContentDialog_PrimaryButtonClick">
<Grid>
<TextBox Text="{x:Bind Path=TestText, Mode=TwoWay}" HorizontalAlignment="Center" VerticalAlignment="Center" MinWidth="100"/>
</Grid>
</ContentDialog>
콘텐츠 대화 코드 :
public sealed partial class ContentDialog1 : ContentDialog, INotifyPropertyChanged
{
public ContentDialog1()
{
InitializeComponent();
}
private string _testText;
public string TestText
{
get => _testText;
set
{
_testText = value;
OnPropertyChanged(nameof(TestText));
}
}
private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
{
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
012 3,516,
그리고 내 목표 SDK verions은 다음과 같습니다 당신은 내용의 대화 상자를 열려면 시작을 클릭하면
는 다음 기본 단추를 클릭 텍스트를 입력 - 당신은 클릭 처리기에 중단 점을 경우 당신은 것을 볼 수 있습니다 입력 한 텍스트로 바인딩이 업데이트되지 않았습니다.
도움을 주셔서 감사합니다. 이 문제점을 보여주는 내 코드 버전을 만들고 대상 SDK 정보를 포함 시켰습니다. –