WPF Binding Привязка Dictionary с вложенным списком к listbox

Возможно ли привязка Dictionary с внутренним списком ObservableCollection к элементу listbox ? или это можно сделать проще. В данном примере привязки не корректны.


Пояснение: 1)Listbox x:Name="List_dir": отвечает за показ ключей словаря; 2)ListView x:Name="List_dir2" Отвечает за вывод списка(ObservableCollection) по ключу.

Предполагаемый функционал: Создание ключей; Добавление данных в существующий список по ключу; Удаление данных из списка по ключу\Изменение данных из списка по ключу; Поиск ключей в Listbox x:Name="List_dir"

   public class mySelectedItem
    {
        public string Name { get; set; }
        public string Password { get; set; }
        public string Description { get; set; }

        public mySelectedItem(string name, string password,string description)
        {
            Name = name;
            Password = password;
            Description = description;
        }
        
    }

    Dictionary<string, ObservableCollection<mySelectedItem>> dict1 = new Dictionary<string, ObservableCollection<mySelectedItem>>();
   
    public MainWindow()
    {
        InitializeComponent();
        this.DataContext = this;
        dict1.Add("f1", new ObservableCollection<mySelectedItem>());
        dict1["f1"].Add(new mySelectedItem("log1","pas1","desc1"));
        dict1["f1"].Add(new mySelectedItem("log2","pas2","desc2"));
    }

XAML:

        <ListBox x:Name="List_dir" HorizontalAlignment="Stretch" Grid.Row="0"  VerticalAlignment="Stretch" Background="White" Margin="-1,-1,0,-1" ItemsSource="{Binding dict1}" BorderBrush="White" >
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <Image Source="icon/f1.png" MaxWidth="20" MaxHeight="20" Margin="0,0,5,0"/>
                        <TextBlock Text="{Binding Key}" FontFamily="Segoe UI Black" FontSize="14"/>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

<ListView x:Name="List2_dir" ItemsSource="{Binding Asset.dict1.Values}" HorizontalAlignment="Stretch" SelectionChanged="ListView_SelectionChanged" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="Red">
            <ListView.Resources>
                <ContextMenu x:Key="ItemContextMenu">
                    <MenuItem x:Name="menuItem_CopyUsername" Click="menuItem_CopyUsername_Click" Header="Copy Username">
                        <MenuItem.Icon>
                            <Image Source="icon/def.png" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem x:Name="menuItem_CopyPassword" Click="menuItem_CopyPassword_Click" Header="Copy Password">
                        <MenuItem.Icon>
                            <Image Source="icon/def.png" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <Separator />
                    <MenuItem x:Name="menuItem_DeleteCreds" Click="menuItem_DeleteCreds_Click" Header="Delete">
                        <MenuItem.Icon>
                            <Image Source="icon/def.png" />
                        </MenuItem.Icon>
                    </MenuItem>
                </ContextMenu>
            </ListView.Resources>
            <ListView.ItemContainerStyle>
                <Style TargetType="{x:Type ListViewItem}">
                    <Setter Property="ContextMenu" Value="{StaticResource ItemContextMenu}" />
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.View>
                <GridView AllowsColumnReorder="true">
                    <GridViewColumn DisplayMemberBinding="{Binding Path=Name}" Header="Логин" Width="150"/>
                    <GridViewColumn DisplayMemberBinding="{Binding Path=Password}" Header="Пароль" Width="150"/>
                    <GridViewColumn DisplayMemberBinding="{Binding Path=Description}" Header="Описание" Width="200"/>
                </GridView>
            </ListView.View>
        </ListView>

Скриншот программы что должно получиться: введите сюда описание изображения


Ответы (0 шт):