Search code examples
wpfvb.netxamlword-wrapwrappanel

WrapPanel with 2 items WPF


I want to show a big text next to an image, in a resizable window.

I found here that it's pssible to use a WrapPanel, but this control need a fixed width and the width of my window is not fixe.

I tried the following code, but sometimes, the text is placed under the image (depanding on the window size) :

<Border Grid.Row="0" BorderBrush="Black" BorderThickness="1" CornerRadius="1" Background="PaleGoldenrod" Grid.Column="0" Margin="5">
    <StackPanel Orientation="Vertical" Opacity="0.8" >
        <WrapPanel Orientation="Horizontal" Width="{Binding ElementName=RadGridViewFoldersSettingsRSP, Path=Width}">
            <Image Source="/Pics/Resources/btn_about_active.png" Margin="2" Width="20"/>
            <TextBlock Text="blablabla" TextWrapping="WrapWithOverflow" Margin="2" FontStyle="Italic"/>
         </WrapPanel>
     </StackPanel>
 </Border>

This border is above a grid as wide as the window.

Can you help me ?


Solution

  • To resolve my issue, i'm going to another way :

    <Border Grid.Row="0" BorderBrush="Black" BorderThickness="1" CornerRadius="1" Background="PaleGoldenrod" Grid.Column="0" Margin="5">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
    
            <Image Source="/Pics/Resources/btn_about_active.png" Margin="2" Width="20" Grid.Column="0"/>
            <TextBlock Grid.Column="1" Text="BIG TEXT" TextWrapping="WrapWithOverflow" Margin="2" FontStyle="Italic"/>
        </Grid>
    </Border>
    

    Thanks to mm8 for his reactivity !