0

I'm search How to show all my Item, but for that I need to make automatic Heigh of My user control I wish the aparence as the same of :

  <Grid>
      <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="*"/>
        .
        .
        .
        <RowDefinition Height="*"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="*"/>
     </Grid.RowDefinitions >
     <control:Plat Grid.Row="1"></control:Plat>
     <control:Plat Grid.Row="2"></control:Plat>
     <control:Plat Grid.Row="3"></control:Plat>
     .
     .
     .
     <control:Plat Grid.Row="n-2"></control:Plat>
     <control:Plat Grid.Row="n-1"></control:Plat>
     <control:Plat Grid.Row="n"></control:Plat>
  </Grid>

With this code :

<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
    <ColumnDefinition />
    <ColumnDefinition />
    <ColumnDefinition />
</Grid.ColumnDefinitions>

<DockPanel>
    <ItemsControl x:Name="RepasMatin">
        <ItemsControl.ItemTemplate>
            <DataTemplate DataType="classes:C_T_plat">
                <control:Plat ></control:Plat>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
</DockPanel>
<materialDesign:PackIcon Kind="Build" Grid.Column="2" HorizontalAlignment="Right" Cursor="Hand"/>

Best Regards

Adriy
  • 1
  • 1
    Is not clear what is the problem. Do you want to be able to scroll to items which doesn't fit? Then you can either use another control (e.g `ListBox`, but you will be forced to use selection, perhaps this is what you trying to avoid by using `ItemsControl`) or appropriate container (see [this](https://stackoverflow.com/q/2028459/1997232)). – Sinatr Jan 18 '19 at 14:52
  • I don't want to scrol, I want everything to be displayed in the window, but the height of control:Plat is not good Normally I have 3 control:Plat, But It possible the number of control:Plat change. It's depend of an ObservableCollection and I wish all my control:Plat stretch my grid – Adriy Jan 18 '19 at 15:02
  • It looks like layout issue. I am not sure how you want it, but Instead of `Grid` with one row and `DockPanel` you can use `Grid` with two rows (or maybe even three). If you put `ItemsControl` inside autosizable (`Height="auto"`) row, then it will expand when its child become bigger. – Sinatr Jan 18 '19 at 15:27

0 Answers0