リスト内のどのステップを参照できるように、アプリケーションのキー値を表示する必要があります。だから私はitemscontrolと一緒に行くための最良の選択となると思いました。それはうまくいかなかった。バインディングはまったく機能しないようです。私は私の問題にマッチするGoogleのソリューションを見つけられませんでした。すべてのソリューションで一般的なバインディングが機能するようです...WPFバインディングディクショナリのItemsControlが機能しません
バインディングが正常に動作することを示すために次のコードがあります。DataGrid
<DataGrid AutoGenerateColumns="False" ItemsSource="{Binding WizardSteps}">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Key}" Header="Key" />
<DataGridTextColumn Binding="{Binding Value}" Header="Value"/>
</DataGrid.Columns>
</DataGrid>
<ListView ItemsSource="{Binding WizardSteps}">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Key}"></TextBlock>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
しかし、このコードは(商品)を動作しません:とリストビュー、両方が正常に動作
<ItemsControl ItemsSource="{Binding WizardSteps}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Key}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
のC#:
public Dictionary<string, PageViewModelBase> WizardSteps { get; set; } =
new Dictionary<string, PageViewModelBase>();
private void _CreateWizardSteps()
{
CreateWizardStepsSpecific(WizardSteps);
WizardSteps.Add("Report", new ReportStepViewModel<ReportView>());
WizardSteps.Add("Report1", new ReportStepViewModel<ReportView>());
NotifyOfPropertyChange(() => WizardSteps);
}
を210
私はこれを私に説明することはできません、itemscontrolはlistviewと同じように動作しませんか?
C#コードはどのクラスに属していますか?それはあなたのウィンドウのコード部分ですか? –
@ stop-cranいいえ、それはユーザーコントロールのデータコンテキストです –
@ViViデータガードは正常に動作しますが、唯一の問題は項目が表示されないitemscontrolです。 –