AvaloniaCommunity / Material.Avalonia

Material design in AvaloniaUI
MIT License
845 stars 79 forks source link

SnackbarHost HostName="Root”, an item with the same key #405

Closed yoyody closed 3 weeks ago

yoyody commented 1 month ago

Usage Information

Material.Avalonia:3.7.4 ; Avalonia :11.1.3; Windows11;IDE: VS2022

Description

<dialogHostAvalonia:DialogHost x:Name="DialogHost" Identifier="MainDialogHost">
    <controls:SnackbarHost HostName="Root" TemplateApplied="TemplatedControl_OnTemplateApplied">
        <controls:NavigationDrawer Name="LeftDrawer"
                                   Classes="permanent"
                                   LeftDrawerOpened="{Binding ElementName=NavDrawerSwitch, Path=IsChecked, Mode=TwoWay}">
            <controls:NavigationDrawer.LeftDrawerContent>
                <ScrollViewer>
                    <StackPanel>
                        <controls:ColorZone Height="55" Mode="Accent">
                            <StackPanel>
                                <TextBlock Margin="15"
                                           HorizontalAlignment="Center"
                                           Classes="Subtitle1"
                                           Text="MyTodo-Avalonia版" />
                            </StackPanel>
                        </controls:ColorZone>
                        <ListBox Name="DrawerList"
                                 Classes="NoScroll"
                                 Focusable="{Binding ElementName=LeftDrawer, Path=LeftDrawerOpened}">
                            <ListBox.Styles>
                                <Style Selector="ListBoxItem">
                                    <Setter Property="Height" Value="48" />
                                    <Setter Property="Padding" Value="16,0" />
                                    <Setter Property="VerticalContentAlignment" Value="Center" />
                                </Style>
                            </ListBox.Styles>
                            <ListBoxItem>首页</ListBoxItem>
                            <ListBoxItem>待办事项</ListBoxItem>
                            <ListBoxItem>备忘录</ListBoxItem>
                            <ListBoxItem>设置</ListBoxItem>
                        </ListBox>
                    </StackPanel>
                </ScrollViewer>
            </controls:NavigationDrawer.LeftDrawerContent>

Reproduction Steps

When editing code 2024-09-30_114410

Expected Behavior

  1. MainWindow.axaml
  2. MainView.axaml

Actual Behavior

An item with the same key has already been added. Key: Root MyTodo D:\vs-source\avalonia-todo\MyTodo\Views\MainView.axaml

Regression?

No response

Known Workarounds

No response

Anything else?

No response

Could you help with a pull-request?

No

Is there an existing issue for this?

yoyody commented 1 month ago

The program can run normally, but it cannot preview the effect when writing code

SKProCH commented 1 month ago

Hello, @yoyody

I can't reproduce it in Rider, code looks like fine.

The program can run normally, but it cannot preview the effect when writing code

This probably should be reported to Avalonia or Avalonia VS previewer extension.

SKProCH commented 3 weeks ago

Closing this issue as staled. Feel free to reopen it or create a new one if the problem persists or you have any questions.