Silverlight popup滚动条在错误的地方 - XAML布局噩梦

时间:2014-01-02 20:38:09

标签: c# silverlight

感谢您的光临。

我遇到弹出窗口容器上出现滚动条而不是数据网格的问题。

因此,如果我将窗口调整为小于网格,则将水平/垂直滚动条放在整个弹出窗口中,而不是显示在数据网格上。这个想法是 - 当您展开窗口时,数据网格按比例占用更多空间,并且随着它缩小,它占用更少的空间,并且如果需要,滚动条将被放置到位以便始终完全看到内容。

以下代码是一个完美的例子,滚动条位于内容上,而不是容器上(即包含此文本的虚线。

< - ! - 以下代码 - >

<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>

1 个答案:

答案 0 :(得分:0)

将我的评论转换为答案:

我非常确定ViewBase的模板有ScrollViewer导致问题。