2

I've found an solution of my problem.

Width=”{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=x:Type Expander}}, Path=ActualWidth}”

But I've got not correct width. (the width of the toggle button is not taken into consideration) Is there any solutions in XAML for this?

Result

<Page x:Class="Restore.Page1"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:local="clr-namespace:Restore"
      mc:Ignorable="d" 
      d:DesignHeight="300" d:DesignWidth="300"
      Title="Page1">

    <Grid Background="AliceBlue" HorizontalAlignment="Stretch">


        <Expander Name="EXPANDER_NAME">
            <Expander.Header>
                <Grid Background="Red" Width="{Binding ElementName=EXPANDER_NAME, Path=ActualWidth}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="30"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Text="sdfsfsd" Grid.Column="0" />
                    <Button Content="OK" Grid.Column="1" />
                </Grid>
            </Expander.Header>
        </Expander>

    </Grid>
</Page>
Community
  • 1
  • 1
isxaker
  • 8,446
  • 12
  • 60
  • 87

0 Answers0