Skip to content

RelativeSource FindAncestor, AncestorType='System.Windows.Controls.Expander', AncestorLevel='1' #3890

@liuyafei518

Description

@liuyafei518

Bug explanation

why my app show bind error ?
this is Error description:
bindPath: ExpandDirection
target: RotateTransform.Angle
description: Unable to find resources: RelativeSource FindAncestor, AncestorType='System.Windows.Controls.Expander', AncestorLevel='1'

this is my code :
<ListBox.ItemTemplate>



<materialDesign:PackIcon
Width="24"
Height="24"
Margin="0,0,5,0"
Foreground="White"
Kind="{Binding Icon}" />


            <Expander.Header>
                <StackPanel x:Name="ExpandHeader" Orientation="Horizontal">
                    <materialDesign:PackIcon
                        Width="24"
                        Height="24"
                        Margin="0,0,5,0"
                        Foreground="White"
                        Kind="{Binding Icon}" />
                    <TextBlock
                        Margin="10,0,10,0"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Center"
                        FontSize="14"
                        FontWeight="Bold"
                        Foreground="White"
                        Text="{Binding Header}" />
                </StackPanel>

            </Expander.Header>
            <ListView
                x:Name="ListViewMenu"
                Foreground="White"
                ItemsSource="{Binding SubItems}"
                ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                SelectionChanged="ListViewMenu_SelectionChanged">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel
                            x:Name="subItemPanel"
                            Margin="18,0,0,0"
                            Orientation="Horizontal">
                            <materialDesign:PackIcon
                                Width="20"
                                Height="20"
                                Margin="0,0,10,0"
                                VerticalAlignment="Center"
                                Foreground="White"
                                Kind="{Binding Icon}" />
                            <TextBlock
                                Padding="5"
                                VerticalAlignment="Center"
                                FontSize="14"
                                Text="{Binding Header}" />
                        </StackPanel>

                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </Expander>
    </StackPanel>
</DataTemplate>

</ListBox.ItemTemplate>

Version

5.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions