Question

This has to be super simple and just missing it. I have an AutoComplete box and it is not filling the entire space of the box; Sample view of AutoComplete

The yellow box is added to the image not part of the actual program. The border for each row is added to visually see the space each is taking. Here is the XML for DataTemplate;

<Border Height="Auto" BorderBrush="Black" BorderThickness="1" >
<Grid HorizontalAlignment="Stretch">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="5*"/>
        <ColumnDefinition Width="3*"/>
        <ColumnDefinition Width="2*"/>
    </Grid.ColumnDefinitions>
    <StackPanel Grid.Column="0">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="2"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <StackPanel Orientation="Vertical" Grid.Column="0">
                <TextBlock Text="Description:" Foreground="Gray" Margin="2,0,2,0" />
                <TextBlock Text="Item ID:" Foreground="Gray" Margin="2,0,2,0" />
            </StackPanel>
            <StackPanel Orientation="Vertical" Grid.Column="2">
                <TextBlock Text="{Binding Descrip}" Margin="2,0,2,0" />
                <TextBlock Text="{Binding ItemID}" Margin="2,0,2,0" />
            </StackPanel>
        </Grid>
    </StackPanel>
    <StackPanel Grid.Column="1">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="2"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <StackPanel Orientation="Vertical" Grid.Column="0">
                <TextBlock Text="Department ID:" Foreground="Gray" Margin="2,0,2,0" />
                <TextBlock Text="Class ID:" Foreground="Gray" Margin="2,0,2,0" />
            </StackPanel>
            <StackPanel Orientation="Vertical" Grid.Column="2">
                <TextBlock Text="{Binding DepartmentID}" Margin="2,0,2,0" />
                <TextBlock Text="{Binding ClassID}" Margin="2,0,2,0" />
            </StackPanel>
        </Grid>
    </StackPanel>
    <StackPanel Grid.Column="3" HorizontalAlignment="Right">
        <TextBlock Margin="2,0,0,2" FontSize="16" FontWeight="Bold"  >
            <Run Text="$" />
            <Run Text="{Binding Price}" />
        </TextBlock>
    </StackPanel>
</Grid>
</Border>

No correct solution

OTHER TIPS

Thanks to @gomi42 this worked;

<Style  x:Key="autoBoxStyle" TargetType="ListBoxItem">
     <Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top