オブジェクトのリストと、グリッド内のいくつかのフィールドがあります。List( ) 内のオブジェクトが選択されると、Grid ( )lvInvoices
の dataBinding を更新します。lyDetailForm
private void lvInvoices_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int index = lvInvoices.SelectedIndex;
if (index != -1)
{
Invoice selectedInvoice = this.ListItems.ElementAt(index);
lyDetailForm.DataContext = selectedInvoice;
((PdfViewer)this.pdfControlHost.Child).File = selectedInvoice.SourceFile.FullName;
}
}
にはlyDetailForms
、いくつかのコントロールがあります。グリッドの DataContext を設定すると、テキスト コントロールが正しく更新されます。それでも、一度設定するまでコンボボックスは白く表示されます。その後、選択したアイテムを変更すると正しく更新されます。
<Grid Name="lyDetailForm" Height="Auto" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Column="2" Grid.Row="1" Margin="10">
<TextBox Name="tbNif" Grid.Column="1" Grid.Row="1" HorizontalAlignment="Left" Width="100" Margin="5" IsEnabled="{Binding SpId, Converter={x:Static local:SpSentToBooleanConverter.Instance}, ConverterParameter=NEGATE, FallbackValue=False}" Text="{Binding Nif,ValidatesOnExceptions=True,NotifyOnValidationError=True}" Validation.Error="OnEditBoxError"/>
<ComboBox Name="cbType" Grid.Column="1" Grid.Row="2" Grid.RowSpan="2" Height="23" HorizontalAlignment="Left" Margin="5" VerticalAlignment="Top" Width="100" IsEnabled="{Binding SpId, Converter={x:Static local:SpSentToBooleanConverter.Instance}, ConverterParameter=NEGATE, FallbackValue=False}" Text="{Binding Type, Mode=TwoWay} ItemsSource="{Binding Types}"/>
</Grid>
ちなみに、は同じオブジェクトTypes
の static プロパティで、 string の配列を返します。コンボボックスの項目は文字列です。invoice
String[]
助言がありますか?前もって感謝します。