Silverlight 验证摘要屏幕空间

发布于 2024-08-05 07:56:49 字数 1320 浏览 5 评论 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、Auto 和 * 的哪种组合。那里有任何推手可以帮忙吗?

谢谢, 标记

Silverlight 3;

I have a ValidationSummary in the top row of my grid. When the ValidationSummary appears, it pushes my button row (row 3) off the bottom of the displayable screen.

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

I'm a code monkey not a pixel pusher and can't figure out which combination of Stretch's, Auto's and *'s I need. Any pushers out there that can help??

Thanks,
Mark

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

墨小沫ゞ 2024-08-12 07:56:49

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

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

MyValidationSummary.Target = TheNewGrid

您可能不想在没有错误的情况下看到滚动查看器,因此将其设置为折叠并使其仅在验证时可见摘要有错误:

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>

I was able to do this by making the validationsummary control a child of scrollview with a maxheight set. This limits the ability of the validationsummary to stretch beyond its parent's maxheight.

Because by default, validationsummary controls use a getparent() to determine the control they are validating, this requires you to manually override the target when the appication innitializes (in vb I do it in the new() routine of my page class.

MyValidationSummary.Target = TheNewGrid

You probably don't want to see the scrollviewer when there are no errors, so set it to Collapsed and in the make it visible only with the validationsummary has errors:

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

I can't seem to get this editor to not screw up the xaml, here's a link:
example

<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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文