Silverlight 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和我需要哪种组合。那里的任何推动者都可以帮忙吗?
谢谢, 标记
答案 0 :(得分:0)
我能够通过使validationsummary控件成为具有maxheight设置的scrollview的子项来实现此目的。这限制了验证总结超出其父级最大值的能力。
因为默认情况下,validationsummary控件使用getparent()来确定他们正在验证的控件,这需要您在appite innitializes时手动覆盖目标(在vb中我在我的页面类的new()例程中执行它)
MyValidationSummary.Target = TheNewGrid
您可能不希望在没有错误时看到滚动查看器,因此将其设置为Collapsed,并且只有在validationsummary有错误时才能看到它:
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,这是一个链接: 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>