ComboBoxで現在選択している項目が表示されない

ComboBoxを使用したカスタムアクティビティを作成しようとしています。(LogMessageと同様の形のアクティビティ)
アクティビティを表示するとComboBox上に現在選択している項目が表示されない状態となってしまいます。
選択肢から選択を行うと表示されるのですが、再表示をすると何も表示されない状態に戻ってしまいます。(選択はされている)
Designerの書き方が良くないと思われるのですが、正しい記述方法を教えて頂きたいです。
(LogMessageのコードが閲覧できれば嬉しいのですが)

以下Designerの一部

Designer.xaml

...
    <sad:ActivityDesigner.Resources>
        <ResourceDictionary>
            <sadc:ArgumentToExpressionConverter x:Key="ArgumentToExpressionConverter" />
            <c:ListLevel x:Key="ListItem" />
        </ResourceDictionary>
    </sad:ActivityDesigner.Resources>
...
        <Label Grid.Row="0" Grid.Column="0" HorizontalAlignment="Right" Content="Item"/>
        <ComboBox
            Grid.Row="0" Grid.Column="1"
            ItemsSource="{Binding ItemsSource, Source={StaticResource ListItem}}"
            SelectedValue="{Binding Path=ModelItem.ListItem, Mode=TwoWay}" SelectedIndex="0">
        </ComboBox>
...

Designer.xaml.cs

...
    public partial class Designer
    {
        public Designer()
        {
            InitializeComponent();
        }
    }
    public class ListItem
    {
        public string[] ItemsSource { get; private set; }

        public ListItem()
        {
            ItemsSource = new string[] { "A", "B", "C" };
        }
    }
...

こんにちは

(LogMessageのコードが閲覧できれば嬉しいのですが)

以下にUiPath.Cryptography.Activities Packageに含まれているDecryptFile ActivityのDesigner xamlソースがあるので、Bindの仕方含めて追いかけてみてはいかがでしょうか?
AlgorithmプロパティがComboboxです。

回答ありがとうございます。

以下を参考にしまして実装を修正した所、表示されるようにすることができました。
ありがとうございました。

https://github.com/UiPath/Community.Activities/blob/master/Activities/Cryptography/UiPath.Cryptography.Activities.Design/DecryptFileActivityDesigner.xaml
https://github.com/UiPath/Community.Activities/blob/master/Activities/Cryptography/UiPath.Cryptography.Activities.Design/DecryptFileActivityDesigner.xaml.cs
https://github.com/UiPath/Community.Activities/blob/master/Activities/Shared/UiPath.Shared/LocalizedEnum.cs
https://github.com/UiPath/Community.Activities/blob/master/Activities/Cryptography/UiPath.Cryptography/SymmetricAlgorithms.cs
https://github.com/UiPath/Community.Activities/blob/master/Activities/Cryptography/UiPath.Cryptography.Activities/DecryptFile.cs
1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.