현재 YAML 사전을 구문 분석 할 응용 프로그램이 있습니다. 나는 표준형하지 않은, ObservableDictionary
을 사용하고 있음을 당신은 아마 눈치 챘을UWP/XAML에서 사전에 대한 양방향 데이터 바인딩
public class Line
{
private ObservableDictionary<string, string> language = new ObservableDictionary<string, string>();
public Line()
{
Language = new Dictionary<string, string>();
}
// used with the YAML parser
[YamlMember(Alias = "language")]
public Dictionary<string, string> Language { get; set; }
}
- I는 다음과 같습니다 Line
라는 이름의 모델이있다. 이 코드를 other StackOverflow answer에서 가져 왔습니다. 내가 이해할 때 필요한 인터페이스 인 INotifyPropertyChanged
을 설정하는 것입니다.
어쨌든 내 Line
의 경우 ListView
에 언어 약어 및 텍스트 상자로 표시된 번역 사전이 채워져 있습니다. 제가 말하고자하는 것을 더 잘 예시하기 위해 여기 그래픽이 있습니다. 그것은 잘 작동합니다 같은
<ListView
ItemTemplate="{StaticResource LinesTemplateItem}"
ItemsSource="{Binding Value.Language}"
SelectionMode="None">
</ListView>
...
<DataTemplate x:Key="LinesTemplateItem">
<StackPanel Background="Transparent">
<TextBlock Text="{Binding Key}" />
<TextBox Text="{Binding Value, Mode=TwoWay}" />
</StackPanel>
</DataTemplate>
모든 것 같습니다 : 함께, 그들은 다음과 같이 - 내 App.xaml
에서
, 나는 정의 내 ListView를위한 DataTemplate
있습니다. 내 데이터가 올바르게 표시됩니다. 나는 어떤 이유로 데이터 바인딩 내부 대신 텍스트의 전체 UI 제어를 목표로하고 있음을 추측 할 오류에서
Error: Cannot save value from target back to source.
BindingExpression: Path='Value' DataItem='Windows.Foundation.Collections.IKeyValuePair`2<String,String>';
target element is 'Windows.UI.Xaml.Controls.TextBox' (Name='null');
target property is 'Text' (type 'String').
: 나는 값을 변경할 때, 그것은 오류가있는 기본 소스를 업데이트하지 않습니다 그것의. 잠시 동안 검색했지만이 오류를 해결하는 방법을 알아낼 수 없습니다. 어떤 도움을 주셔서 감사합니다. 감사.