Scaling problem in UniformGrid

I have another problem with scaling in a UniformGrid. When I use the code below the images look fine in their cells but the text in cell 0,0 and even the header of the groupbox is scaled down too much. How can I prevent the scaling of the image to have an effect on the rest of the grid Thanks for your help ;-)

<GroupBox Header="{Binding Path=ItemHeader}" HeaderTemplate="{StaticResource rightAlignedHeaderTemplate}">

<UniformGrid Rows="4" Columns="2">

<Grid>

<Grid.ColumnDefinitions>

<ColumnDefinition/>

</Grid.ColumnDefinitions>

<Grid.RowDefinitions>

<RowDefinition/>

</Grid.RowDefinitions>

<TextBlock Grid.Column="0" Grid.Row="0" FontSize="20">

<TextBlock Background="White" Text="{Binding Path=MyText}"/>

<TextBlock Text="2"/>

</TextBlock>

</Grid>

<Grid/>

<Grid/>

<Border Grid.Column="1" Grid.Row="1" BorderThickness="2">

<Image Source="{Binding Path=ImageName1}" Stretch="Uniform"/>

</Border>

<Grid/>

<Border Grid.Column="1" Grid.Row="2" BorderThickness="2">

<Image Source="{Binding Path=ImageName2}" Stretch="Uniform"/>

</Border>

</UniformGrid>

</GroupBox>



Answer this question

Scaling problem in UniformGrid

  • Cyber Sinh

    What do you mean by scaling exactly There are no Transforms or Viewboxes in the XAML you posted so I don't see any reason the text would change size

    Since you are using a UniformGrid every cell will always be the same size.


  • Thara Riaz

    Ok, I solved it somehow. I didn't mention, that code was part for a DataTemplate for a ListView that was embedded inside a ViewBox which was inside a ScrollViewer like this:

    <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled">

    <Viewbox>

    <ListView ItemTemplate="{StaticResource MyDataTemplate}" ItemsSource="{Binding Path=DataSource}">

    <ListView.ItemsPanel>

    <ItemsPanelTemplate>

    <VirtualizingStackPanel Orientation="Horizontal" Background="LightGray"/>

    </ItemsPanelTemplate>

    </ListView.ItemsPanel>

    </ListView>

    </Viewbox>

    </ScrollViewer>

    I just put a Width and a Height on the Images in the first post and now I can set the text sizes relatively to that and eveyrhing looks OK. ;-)


  • Scaling problem in UniformGrid