views:

32

answers:

1

I need to place objects 40% 40% 20% and that there were no scroll

 <Grid Grid.Row="1">
 <Grid.RowDefinitions>
  <RowDefinition Height="40*"  />
  <RowDefinition Height="40*"  />
  <RowDefinition Height="20*"/>
 </Grid.RowDefinitions>
 <Grid.ColumnDefinitions>
  <ColumnDefinition/>
  <ColumnDefinition/>
  <ColumnDefinition/>
  <ColumnDefinition/>
 </Grid.ColumnDefinitions>
 <DockPanel x:Name="stack_d"  Grid.Row="0" Grid.ColumnSpan="4"  VerticalAlignment="Stretch"  >
  <l:CategoryView HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
 </DockPanel>
 <DockPanel x:Name="stack_trainer" Grid.Row="1" Grid.ColumnSpan="4"   DockPanel.Dock="Bottom" >
  <loc:TrainerView />
 </DockPanel>

 <Button Content="Почта" x:Name="mails" Grid.Row="2" Grid.Column="0"  Width="100" HorizontalAlignment="Center" VerticalAlignment="Stretch"  Click="mails_Click"/>
 <Button Content="Оплатить" Width="100" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Stretch"  Click="Button_Click_Payment"/>
 <Button Content="Тех помощь" Width="100" Grid.Row="2" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Stretch"  x:Name="support" Click="support_Click"/>
 <Button Content="Настройки" x:Name="settings" Grid.Row="2" Grid.Column="3"   Width="100" HorizontalAlignment="Center" VerticalAlignment="Stretch" Click="settings_Click"/>
</Grid>

but i have problem. see images

alt text

alt text

UserControl Top:

<ScrollViewer VerticalScrollBarVisibility="Auto" >
    <Border>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <TextBlock Text="Категории" Grid.Row="0" HorizontalAlignment="Center" Style="{StaticResource TextBlockTitle}"/>
            <ListBox Grid.Row="1" x:Name="list_category"  ItemsSource="{Binding Tables[0]}">
                <ListBox.Resources>
                    <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"/>
                    <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black"/>
                    <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="#00FFFFFF"/>
                </ListBox.Resources>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <GroupBox Header="Категория" Width="300" HorizontalAlignment="Stretch" x:Name="GroupBox">
                            <DockPanel Tag="{Binding id}">
                                <Button Click="Button_Click" DockPanel.Dock="Top" >
                                    <Button.Content>
                                        <DockPanel>
                                            <TextBlock Text="{Binding title}" TextWrapping="Wrap" DockPanel.Dock="Top" Padding="5"  HorizontalAlignment="Center"  Foreground="#FFB51414" />
                                            <l:ScrollViewerEx  VerticalScrollBarVisibility="Auto" >
                                                <TextBlock Text="{Binding description}" DockPanel.Dock="Top" TextWrapping="Wrap" Padding="5" IsHitTestVisible="False" />
                                            </l:ScrollViewerEx>
                                        </DockPanel>
                                    </Button.Content>
                                </Button>
                            </DockPanel>
                        </GroupBox>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Grid>
    </Border>
</ScrollViewer>

next UserControl

<ScrollViewer VerticalScrollBarVisibility="Auto" Background="Transparent">
 <Border Background="Transparent">
  <Grid>
   <Grid.RowDefinitions>
    <RowDefinition Height="Auto" />
    <RowDefinition Height="Auto" />
    <RowDefinition />
   </Grid.RowDefinitions>
   <TextBlock Text="Сопровождающие" Grid.Row="1" HorizontalAlignment="Center" Style="{StaticResource TextBlockTitle}"/>
   <ListBox Grid.Row="2" x:Name="list_category" Background="Transparent"  ItemsSource="{Binding Tables[0]}"  VerticalContentAlignment="Stretch"  >
    <ListBox.Resources>
     <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"/>
     <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black"/>
     <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="#00FFFFFF"/>
    </ListBox.Resources>
    <ListBox.ItemTemplate>
     <DataTemplate>
      <GroupBox Header="Сопровождающие" Width="300"  VerticalAlignment="Stretch" VerticalContentAlignment="Stretch"  HorizontalAlignment="Stretch" x:Name="GroupBox" Background="Transparent">
       <DockPanel Tag="{Binding id_Person}"  VerticalAlignment="Stretch" Background="Transparent">
        <Button Click="Button_Click" DockPanel.Dock="Top">
         <Button.Content>
          <DockPanel VerticalAlignment="Stretch">
           <StackPanel DockPanel.Dock="Top" Orientation="Horizontal" HorizontalAlignment="Center">
            <TextBlock Text="{Binding surname}" Padding="5"  HorizontalAlignment="Center"  Foreground="#FFB51414" />
            <TextBlock Text="{Binding name}" Padding="5"  HorizontalAlignment="Center"  Foreground="#FFB51414" />
            <TextBlock Text="{Binding lastname}" Padding="5"  HorizontalAlignment="Center"  Foreground="#FFB51414" />
           </StackPanel>
           <Grid DockPanel.Dock="Bottom">
            <Grid.RowDefinitions>
             <RowDefinition />
             <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
             <ColumnDefinition />
             <ColumnDefinition />
             <ColumnDefinition />
             <ColumnDefinition />
             <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <TextBlock Text="{Binding quarter}" x:Name="quarter" Padding="5" Grid.Column="2"  Grid.Row="1" HorizontalAlignment="Center"  Foreground="#FFB51414" />
            <TextBlock Text="{Binding halfyear}" x:Name="halfyear" Padding="5" Grid.Column="3" Grid.Row="1"  HorizontalAlignment="Center"  Foreground="#FFB51414" />
            <TextBlock Text="{Binding year}" x:Name="year" Padding="5" Grid.Column="4"  Grid.Row="1" HorizontalAlignment="Center"  Foreground="#FFB51414" />

            <TextBlock Text="Период: " Padding="5" Grid.Column="1"    HorizontalAlignment="Center"  Foreground="#FFB51414" />

            <TextBlock Text="Квартал" Padding="5" Grid.Column="2"   HorizontalAlignment="Center"  Foreground="#FFB51414" />
            <TextBlock Text="Полгода" Padding="5" Grid.Column="3"   HorizontalAlignment="Center"  Foreground="#FFB51414" />
            <TextBlock Text="Год" Padding="5" Grid.Column="4"  HorizontalAlignment="Center"  Foreground="#FFB51414" />
            <TextBlock Text="Цена: " Padding="5" Grid.Row="1"  Grid.Column="1"  HorizontalAlignment="Center"  Foreground="#FFB51414" />
           </Grid>
           <Grid DockPanel.Dock="Top"  >
            <Image Source="{Binding photo}"/>
           </Grid>
          </DockPanel>
         </Button.Content>
        </Button>
        <Button DockPanel.Dock="Bottom" x:Name="send_mess" Tag="{Binding id_Person}" Click="send_mess_Click" Content="Написать сопровождающему"/>
        <DockPanel DockPanel.Dock="Bottom" HorizontalAlignment="Center" Tag="{Binding id_Person}" >
         <ComboBox VerticalAlignment="Top" x:Name="combobox_term">
          <ComboBoxItem Content="Квартал" Tag="1"/>
          <ComboBoxItem Content="Полгода" Tag="2"/>
          <ComboBoxItem Content="Год" Tag="3" IsSelected="True"/>
         </ComboBox>
         <CheckBox Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked" IsChecked="{Binding id_Person, Converter={StaticResource CheckBoxToCheked}}" Content="Выбрать" />
        </DockPanel>

       </DockPanel>
      </GroupBox>
     </DataTemplate>
    </ListBox.ItemTemplate>
   </ListBox>
  </Grid>
 </Border>
</ScrollViewer>

this is all happening because of the pictures, how to fight it?

listbox and groupbox - I have their styles if they are needed I can provide them

EDIT:

parent Grid

<ScrollViewer VerticalScrollBarVisibility="Auto" >
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <Grid Grid.Row="0" x:Name="gridrtfbox" Visibility="Collapsed">
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                </Grid>
                <Grid Grid.Row="1">...
A: 

I use convert

<GroupBox Header="Сопровождающие" Width="300" HorizontalAlignment="Stretch" x:Name="GroupBox" Background="Transparent" Height="{Binding ElementName=list_category, Converter={StaticResource ConSetHeigthKey}}">

converter:

public class ConSetHeigthTrainer : IValueConverter
        {
            public object Convert(object value, Type targetType, object parameter,
                                  CultureInfo culture)
            {
                try
                {
                    return (value as System.Windows.Controls.ListBox).ActualHeight-20;
                }
                catch (Exception Exception) { return (value as System.Windows.Controls.ListBox).ActualHeight - 20; }
            }

            public object ConvertBack(object value, Type targetType, object parameter,
                                      CultureInfo culture)
            {
                throw new NotImplementedException();
            }
        }
simply denis