Xceed PropertyGrid を使用して、ハードコードされた文字列値でドロップダウンを表示しようとしています。として割り当てる文字列として項目を表示する代わりにIItemSource
、PropertyGrid は、ドロップダウンの各項目に対して "Xceed.Wpf.Toolkit.PropertyGrid.Attributes.Item" を表示します。オブジェクトを選択すると、目的の文字列が選択されたアイテムとして表示されます。
これは私が見るドロップダウン項目です:
また、アイテムを選択すると、ドロップダウン アイテムとしても希望どおりに表示できます。
私のコード:
XAML:
<xctk:PropertyGrid SelectedObject="{Binding MySettingsWrapper}" AutoGenerateProperties="True">
</xctk:PropertyGrid>
C#:
[Serializable]
public class SettingsWrapper
{
[LocalizedCategory("SettingsViewCategoryHardware")]
[LocalizedDisplayName("SettingsViewLblSelectPrinter")]
[ItemsSource(typeof(PrintersItemSource))]
public string SelectedPrinter { get; set; }
public class PrintersItemSource : IItemsSource
{
public ItemCollection GetValues()
{
var printers = new ItemCollection();
for (int i = 0; i < 7; i++)
{
printers.Add("Option - " + i);
}
return printers;
}
}
}
私は Caliburn.Micro を使用しています。
私はいくつかのことを試しましたが、アイデアがありません。どんな助けでも大歓迎です。