0

我正在尝试使 Silverlight 中的 ValidationSummary 可滚动。它不起作用,我不确定我做错了什么。

包裹在 ScrollViewer 中时,不会显示验证摘要。

<UserControl x:Class="SilverlightDataValidation.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ct="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input"       
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">

<Grid x:Name="LayoutRoot" Background="White" BindingValidationError="LayoutRoot_BindingValidationError">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="55" />
        <ColumnDefinition Width="345" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="25" />
        <RowDefinition Height="25" />
        <RowDefinition Height="25" />
        <RowDefinition Height="25" />
        <RowDefinition Height="160" />
        <RowDefinition Height="40*" />
    </Grid.RowDefinitions>
    <ScrollViewer Grid.Row="4" Height="135" HorizontalAlignment="Left" Margin="0,4,0,0" Name="scrollViewer1" VerticalAlignment="Top" MaxHeight="200" Width="333" Grid.Column="1" HorizontalScrollBarVisibility="Auto">
        <ct:ValidationSummary Width="300" Grid.Column="1" Margin="0,0,45,0" />
    </ScrollViewer>
    <TextBox Name="txtName" Text="{Binding Name, Mode=TwoWay, ValidatesOnExceptions =True, NotifyOnValidationError=True, UpdateSourceTrigger=Explicit}"
             Grid.Column="1" Grid.Row="1" 
             Height="23" HorizontalAlignment="Left" VerticalAlignment="Top" Width="185" />

    <TextBox Name="txtAge" 
             Text="{Binding Age, Mode=TwoWay, ValidatesOnExceptions=True, NotifyOnValidationError=True, UpdateSourceTrigger=Explicit}"
             Grid.Column="1" Grid.Row="2" 
             Height="23" HorizontalAlignment="Left"  VerticalAlignment="Top" Width="120" />

    <Button Content="Save" Grid.Column="1" Grid.Row="3" 
            Height="23" HorizontalAlignment="Left" Name="butSave" VerticalAlignment="Top" Width="75" Click="butSave_Click"  />

    <TextBlock Grid.Row="1" Name="textBlock1" Text="Name" 
               VerticalAlignment="Top" Margin="22,0,0,0" Height="23" HorizontalAlignment="Left" />
    <TextBlock Grid.Row="2"  Name="textBlock2" Text="Age" 
               VerticalAlignment="Top" Margin="34,0,0,0" Height="23" HorizontalAlignment="Left" />
</Grid>

当您从 ScrollViewer 中删除验证摘要时,它会显示。

4

1 回答 1

0

不需要 ScrollView,可以通过在 ValidationSummary 上设置 maxheight 属性来实现相同的效果

于 2012-06-19T17:15:11.007 回答