0

银光 3;

我在网格的第一行有一个 ValidationSummary。当 ValidationSummary 出现时,它将我的按钮行(第 3 行)推离可显示屏幕的底部。

<Grid HorizontalAlignment="Stretch"
          VerticalAlignment="Stretch">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="36" />
        </Grid.RowDefinitions>

        <di:ValidationSummary Grid.Row="0" />

        <Grid x:Name="gridOuterContentHolder"
              Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="0.68*" />
                <RowDefinition Height="5" />
                <RowDefinition Height="0.32*" />
            </Grid.RowDefinitions>
<!-- elements removed for brevity -->

        </Grid>

        <StackPanel x:Name="stack"
                    Grid.Row="2"
                    Orientation="Horizontal"
                    HorizontalAlignment="Right">
            <Button Content="Delete"
                    x:Name="btnDelete"
                    Height="20"
                    Width="75" />

        </StackPanel>
    </Grid>

我是一个代码猴子而不是像素推动者,无法弄清楚我需要哪种 Stretch's、Auto's 和 *'s 组合。有没有可以帮忙的推手??

谢谢,马克

4

1 回答 1

0

我可以通过将validationsummary 控件设置为设置了maxheight 的scrollview 的子项来做到这一点。这限制了验证摘要超出其父级最大高度的能力。

因为默认情况下,validationsummary 控件使用 getparent() 来确定它们正在验证的控件,这需要您在应用程序初始化时手动覆盖目标(在 vb 中,我在我的页面类的 new() 例程中执行此操作。

MyValidationSummary.Target = TheNewGrid

当没有错误时,您可能不希望看到滚动查看器,因此将其设置为 Collapsed 并使其仅在验证摘要可见时出现错误:

Private Sub MyValidationSummary_LayoutUpdated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyValidationSummary.LayoutUpdated
    If MyValidationSummary.HasErrors Then
        svMyValidationSummary.Visibility = Windows.Visibility.Visible
    Else
        svMyValidationSummary.Visibility = Windows.Visibility.Collapsed
    End If
End Sub

我似乎无法让这个编辑器不搞砸 xaml,这是一个链接: 示例

<ScrollViewer Visibility="Collapsed" x:Name="svMyValidationSummary" MaxHeight="200" Margin="6" BorderThickness="1">
    <dataInput:ValidationSummary FocusControlsOnClick="True" x:Name="MyValidationSummary"></dataInput:ValidationSummary>
</ScrollViewer>

<data:DataGrid Margin="10" AutoGenerateColumns="False" Width="1250" x:Name="TheNewGrid"  Height="350">
    <data:DataGrid.Columns>
        <local:DataGridTemplateColumnBindingText  CanUserReorder="False" CanUserResize="False"
                          HeaderStyle='{StaticResource RowHeaderColumnStyle}' >
            <local:DataGridTemplateColumnBindingText.CellEditingTemplate>
                <DataTemplate>
                    <controlsToolkit:DockPanel HorizontalAlignment="Stretch">
                        <StackPanel controlsToolkit:DockPanel.Dock="Right" Orientation="Horizontal">
                            <Button ToolTipService.ToolTip="Insert an empty row" Click="btnInsertRow_Click">
                                <Image Source="add.png"></Image>
                            </Button>
                            <Button ToolTipService.ToolTip="Copy row" Click="btnDuplicateRow_Click">
                                <Image Source="application_double.png"></Image>
                            </Button>
                            <Button  ToolTipService.ToolTip="Delete row" Click="btnDeleteRow_Click">
                                <Image Source="delete.png"></Image>
                            </Button>
                        </StackPanel>
                        <Border BorderThickness="1" Background="PowderBlue">
                            <TextBlock controlsToolkit:DockPanel.Dock="Left" TextAlignment="Center" HorizontalAlignment="Stretch" Text="{Binding SortNumber}"></TextBlock>
                        </Border>
                    </controlsToolkit:DockPanel>
                </DataTemplate>
            </local:DataGridTemplateColumnBindingText.CellEditingTemplate>
        </local:DataGridTemplateColumnBindingText>
    </data:DataGrid.Columns>
</data:DataGrid>
于 2010-04-09T20:44:25.340 回答