简体   繁体   中英

Silverlight popup scrollbars in wrong place - XAML layout nightmare

I appreciate your visit.

I have an issue with scroll bars appearing on the container of the popup rather than on the data grids.

So if i resize the window to be smaller than the grids, it puts horizontal/vertical scrollbars on the whole popup as opposed to appearing on the data grid. The idea would be to - as you expand the window the data grids proportionately take up more room and as it is shrunk smaller it takes up less room and if necessary scroll bars are put in place in order to fully see the content at all times.

The code below is a perfect example, the scroll bars are on the content, not on the container (ie the dotted line which also includes this text.

<-!--Code Below-->

<controls:ViewBase  x:Class="CS.Silverlight.Module.AdminModules.AuditTrailSessions.AuditTrailSessionMainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:CS.Silverlight.Library.Controls;assembly=Library"
xmlns:cal="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation"
xmlns:libraryData="clr-namespace:CS.Library.Controls.Data;assembly=Library.Controls" 
xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
xmlns:telerikPager="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Data"
xmlns:CustomControl="clr-namespace:CS.Library.Controls;assembly=Library.Controls" >

<Grid x:Name="LayoutRoot" HorizontalAlignment="Left">
  <Grid.RowDefinitions>
    <RowDefinition Height="Auto"></RowDefinition>
    <RowDefinition Height="Auto"></RowDefinition>
    <RowDefinition Height="*"></RowDefinition>
    <RowDefinition Height="Auto"></RowDefinition>
    <RowDefinition Height="Auto"></RowDefinition>
    <RowDefinition Height="*"></RowDefinition>
  </Grid.RowDefinitions>

        <StackPanel Grid.Row="0" x:Name="expandStackPanel" Orientation="Horizontal" Visibility="Collapsed">
                      <Image x:Name="ExpandImage" VerticalAlignment="Center"  
                              MouseLeftButtonUp="ExpandImage_MouseLeftButtonUp" 
                              HorizontalAlignment="Left"  Source="{Binding ExpandImage}" 
                              ToolTipService.ToolTip="Expand/Collapse Quick Filter Panel" 
                              ToolTipService.Placement="Top" Stretch="None" Width="20" >
                      </Image>
                      <TextBlock Text="Filter Set:" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="2"/>
                  </StackPanel>

        <Grid Grid.Row="1" x:Name="filterControlsGrid" Visibility="{Binding FilterGridControls}">

                  <Grid Grid.Row="0" Grid.Column="0" Grid.RowSpan="3">
                          <StackPanel Orientation="Horizontal" Margin="2">
                              <Button   Grid.Column="0" Width="30"  cal:Click.Command="{Binding Refresh}"  Margin="2" Height="30"  BorderThickness="0" Cursor="Hand" x:Name="refreshButton"  ToolTipService.ToolTip="Refresh the data with current filter settings." ToolTipService.Placement="Top">
                                  <Button.Content>
                                      <Image Source="{Binding RefreshButton}"  />
                                  </Button.Content>
                              </Button>
                          </StackPanel>
                      </Grid>

                  <StackPanel Grid.Row="0" Grid.Column="1" Orientation="Horizontal" Margin="2" HorizontalAlignment="Left">

                              <TextBlock Text="Object Type:" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="2"/>
                              <ComboBox x:Name="objctTypeComboBox"  Width="200" Margin="2" 
                                    SelectedItem="{Binding SelectedObjectType,Mode=TwoWay}"
                                    DisplayMemberPath="Name" 
                                    ItemsSource="{Binding ObjectTypes}"
                                    VerticalAlignment="Center" HorizontalAlignment="Center" />


                              <TextBlock Text="Action:" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="2"/>
                              <ComboBox x:Name="actionComboBox"  Width="150" Margin="2" 
                                        SelectedItem="{Binding SelectedAction,Mode=TwoWay}"
                                        ItemsSource="{Binding Actions}"
                                        VerticalAlignment="Center" HorizontalAlignment="Center" />

                              <TextBlock Text="User:" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="2" />
                              <ComboBox x:Name="userViewCombobox"  Width="120" Margin="2" 
                                    SelectedItem="{Binding SelectedUsers,Mode=TwoWay}"
                                    DisplayMemberPath="Name" 
                                    ItemsSource="{Binding Users}"
                                    VerticalAlignment="Center" HorizontalAlignment="Center" />

                              <TextBlock Text="Object Id:" VerticalAlignment="Center" Margin="2"/>
                              <TextBox VerticalAlignment="Center" Margin="2" Text="{Binding ObjectId,Mode=TwoWay,NotifyOnValidationError=True,ValidatesOnExceptions=True}" Width="100"/>
                              <Button x:Name="btnVersionHistory" Margin="3,1,3,1" HorizontalAlignment="Left" VerticalAlignment="Center" Width="60" Content="Versions" Click="btnVersionHistory_Click"
                                          ToolTipService.ToolTip="View the version history for this trade."  Visibility="{Binding TradeVersionsVisibility}" ></Button>

                          </StackPanel>

                  <StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal"  Margin="2" HorizontalAlignment="Left">

                              <TextBlock Text="As of Date:" HorizontalAlignment="Right" VerticalAlignment="Center"/>
                              <CustomControl:CustomDatePicker  Width="120" Height="21" SelectedDate="{Binding StartDate,Mode=TwoWay}" HorizontalAlignment="Left"/>
                              <TextBlock Text=" - " HorizontalAlignment="Right" VerticalAlignment="Center"/>
                              <CustomControl:CustomDatePicker  Width="120" Height="21" SelectedDate="{Binding EndDate,Mode=TwoWay}" HorizontalAlignment="Left"/>


                              <TextBlock Text="Description:" VerticalAlignment="Center" Margin="2"/>
                              <TextBox VerticalAlignment="Center" Margin="2" Text="{Binding Description,Mode=TwoWay}" Width="300"/>

                          </StackPanel>

                  <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                      <TextBlock Text="{Binding WarningMessage,Mode=TwoWay}" Foreground="Red"/>
                  </StackPanel>

        </Grid>

        <libraryData:CustomDataGrid Grid.Row="2" x:Name="auditTrailSessionDataGrid"
                                      AutoGenerateColumns="False"
                                      ItemsSource="{Binding AuditTrailSessionInfos,Mode=TwoWay}" 
                                      ShowGroupPanel="True"  
                                      Margin="5" 
                                      IsReadOnly="True" 
                                      VerticalAlignment="Stretch" 
                                      HorizontalAlignment="Stretch"
                                      CanUserFreezeColumns="True" 
                                      CanUserResizeColumns="True"
                                      CanUserReorderColumns="False" 
                                      ClipboardCopyMode="All"
                                      SelectionMode="Single"
                                      GridLinesVisibility="Horizontal"
                                      SelectionChanged="auditTrailSessionDataGrid_SelectionChanged"
                                      FrozenColumnCount="{Binding Value,ElementName=statisticsRadSlider,Mode=TwoWay}"
                                      IsFilteringAllowed="True">
                      <telerik:RadGridView.Columns>
                          <telerik:GridViewDataColumn DataMemberBinding="{Binding ObjectId}" Header="Object Id" />
                          <telerik:GridViewDataColumn DataMemberBinding="{Binding ObjectType}" Header="Type"/>
                          <telerik:GridViewDataColumn DataMemberBinding="{Binding Description}" Header="Description"/>
                          <telerik:GridViewDataColumn DataMemberBinding="{Binding Action}" Header="Action" />
                          <telerik:GridViewDataColumn DataMemberBinding="{Binding UserName}" Header="User"/>
                          <telerik:GridViewDataColumn DataMemberBinding="{Binding UpdateTime}" Header="Date" DataFormatString="yyyy-MM-dd HH:mm:ss"/>
                      </telerik:RadGridView.Columns>
                  </libraryData:CustomDataGrid>

        <telerikPager:RadDataPager Grid.Row="3" x:Name="AuditTrailSessionDataGridPager" Visibility="{Binding DataGridVisibility,Mode=TwoWay}" 
                                          PageSize="15" Margin="0,0,5,0" Source="{Binding Items, ElementName=auditTrailSessionDataGrid}"  
                                          DisplayMode="All"  AutoEllipsisMode="Both" NumericButtonCount="10" IsTotalItemCountFixed="True" />

        <StackPanel Grid.Row="4" x:Name="valueLabelStackPanel" Orientation="Horizontal" HorizontalAlignment="Left" Margin="5">
                <TextBlock Text="Value:"/>
        </StackPanel>

        <libraryData:CustomDataGrid Grid.Row="5" x:Name="auditTrailDetailDataGrid" 
                                        AutoGenerateColumns="False"
                                        ItemsSource="{Binding Details,Mode=TwoWay}" 
                                        ShowGroupPanel="True"  
                                        Margin="5" 
                                        IsReadOnly="True" 
                                        VerticalAlignment="Stretch" 
                                        HorizontalAlignment="Stretch"
                                        CanUserFreezeColumns="True" 
                                        CanUserResizeColumns="True"
                                        CanUserReorderColumns="False" 
                                        ClipboardCopyMode="All"
                                        SelectionMode="Single"
                                        GridLinesVisibility="Horizontal"
                                        ShowGroupFooters="True" 
                                        ShowColumnFooters="True"
                                        FrozenColumnCount="{Binding Value,ElementName=statisticsRadSlider,Mode=TwoWay}"
                                        IsFilteringAllowed="True">
                        <telerik:RadGridView.Columns>
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding ObjectType}" Header="Object Type"/>
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding PropertyName}" Header="Field"/>
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding OldValue}" Header="Old Value"/>
                            <telerik:GridViewDataColumn DataMemberBinding="{Binding NewValue}" Header="New Value"/>
                        </telerik:RadGridView.Columns>
         </libraryData:CustomDataGrid>

    </Grid>

Converting my comment into an answer:

I'm pretty sure the template for ViewBase has a ScrollViewer that is causing the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM