本文介绍了带有UniformGrid图像的WPF ItemsControl.ItemsPanel - 为什么UG溢出父级?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何帮助赞赏..提取下面。 UniformGrid旨在显示不同数量的图像。这样做但图像大小不会调整大小,以便所有图像都可以在父网格内显示。出于某种原因,UniformGrid似乎在网格底部溢出。我希望我做错了吗?



谢谢

Kevin



Any help appreciated.. extract below. UniformGrid is intended to display a varying number of images. This it does but the image sizes DO NOT resize so that all the images can display inside the parent Grid. For some reason the UniformGrid seems to 'overflow' across the bottom of the Grid. I hope I am doing something obvious wrong?

Thanks
Kevin

  <Grid Margin="5">
    <Grid.RowDefinitions>
      <RowDefinition Height="30"/>
      <RowDefinition Height="70"/>
      <RowDefinition Height="*"/>
      <RowDefinition Height="100"/>
    </Grid.RowDefinitions>

<Border Grid.Row="2" Grid.ColumnSpan="2" Name="borderAnswers" >
    <!--  This is the Answer List Grid ............................................................................-->
    <ItemsControl Grid.Row="2" Grid.ColumnSpan="2" Name="AnswerPanel" ItemsSource="{Binding}">
      
      <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
          <UniformGrid Rows="{Binding Source={StaticResource objImageRows}}"

                       Columns="{Binding Source={StaticResource objImageCols}}" 

                       removed="#76F2ECEC">
          </UniformGrid> 
        </ItemsPanelTemplate>
      </ItemsControl.ItemsPanel>
      
       <ItemsControl.ItemTemplate>
        <DataTemplate>
          <Border Name="BorderAnswer" BorderThickness="2" BorderBrush="White" 

                  Margin="5" removed="Gray"

                  Style="{StaticResource CellHighlight}">
            
            <Grid>
              <Grid.RowDefinitions>
                <RowDefinition Name="RowAnswerID" Height="10"></RowDefinition>
                <RowDefinition Name="RowAnswerText" Height="50"></RowDefinition>
                <RowDefinition Name="RowAnswerImage" Height="*"></RowDefinition>
              </Grid.RowDefinitions>
              <TextBlock Grid.Row="0" Name="imgID" Text="{Binding Path=AnswerID}" 

                         FontSize="10" Foreground="White"/>
              <TextBlock Grid.Row="1" Name="imgText" Text="{Binding Path=AnswerText}" 

                         Style="{StaticResource TextBlockStyleAnswers}"/>
              <Image Grid.Row="2"  Name="nameImagePath" Source="{Binding Path=AnswerImagePath}" 

                     Margin="0" Stretch="Fill" 

                     HorizontalAlignment="Stretch"  VerticalAlignment="Stretch" 

                     ClipToBounds="True"/>
            </Grid>
          </Border>
        </DataTemplate>
      </ItemsControl.ItemTemplate>
    </ItemsControl>
</Border>
</Grid>

推荐答案



这篇关于带有UniformGrid图像的WPF ItemsControl.ItemsPanel - 为什么UG溢出父级?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 16:54