というユーザーコントロール内に次のものがありますUserInputOutput
。
<ComboBox Grid.Column="1" Background="White" Visibility="{Binding InputEnumVisibility}"
FontSize="{Binding FontSizeValue}" Width="Auto" Padding="10,0,5,0"
ItemsSource="{Binding EnumItems}"
SelectedIndex="{Binding EnumSelectedIndex}"/>
ここにはいくつかのバインディングがあり、ItemsSource を除いてすべてうまく機能します。これが私の依存関係プロパティとパブリック変数です。
public ObservableCollection<String> EnumItems
{
get { return (ObservableCollection<String>)GetValue(EnumItemsProperty); }
set { SetValue(EnumItemsProperty, value); }
}
public static readonly DependencyProperty EnumItemsProperty =
DependencyProperty.Register("EnumItems", typeof(ObservableCollection<string>),typeof(UserInputOutput)
ComboBox の ItemSource を除いて、すべてのバインディングは XAML で設定されます。これは実行時に設定する必要があります。私のコードでは、次を使用します。
ObservableCollection<string> enumItems = new ObservableCollection<string>();
UserInputOutput.getEnumItems(enumItems, enumSelectedIndex, ui.ID, ui.SubmodeID);
instanceOfUserInputOutput.EnumItems = enumItems;
XAML がファイルから読み込まれた後に、このコードを実行します。enumItemsinstaceOfUserInputOutput.EnumItems
に設定した後、正しい項目が含まれていますが、プログラムのコンボ ボックスに表示されません。
ここでどこが間違っているのかわかりません。何かご意見は?
ありがとうございました!