如何在silverlight中为Word Wrap启用ValidationSummary?

时间:2012-06-21 00:22:48

标签: silverlight silverlight-4.0

当错误消息是长字符串时,如何使消息在ValidationSummary中显示为多行?

1 个答案:

答案 0 :(得分:0)

toolTips的一个示例:

<ControlTemplate x:Key="ValidationToolTipTemplate">
    <Grid x:Name="Root"
            Margin="5,0"
            Opacity="0"
            RenderTransformOrigin="0,0">
        <Grid.RenderTransform>
            <TranslateTransform x:Name="xform" X="-25" />
        </Grid.RenderTransform>
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="OpenStates">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0" />
                    <VisualTransition GeneratedDuration="0:0:0.2" To="Open">
                        <Storyboard>
                            <DoubleAnimation Duration="0:0:0.2"
                                                Storyboard.TargetName="xform"
                                                Storyboard.TargetProperty="X"
                                                To="0">
                                <DoubleAnimation.EasingFunction>
                                    <BackEase Amplitude=".3" EasingMode="EaseOut" />
                                </DoubleAnimation.EasingFunction>
                            </DoubleAnimation>
                            <DoubleAnimation Duration="0:0:0.2"
                                                Storyboard.TargetName="Root"
                                                Storyboard.TargetProperty="Opacity"
                                                To="1" />
                        </Storyboard>
                    </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="Closed">
                    <Storyboard>
                        <DoubleAnimation Duration="0"
                                            Storyboard.TargetName="Root"
                                            Storyboard.TargetProperty="Opacity"
                                            To="0" />
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Open">
                    <Storyboard>
                        <DoubleAnimation Duration="0"
                                            Storyboard.TargetName="xform"
                                            Storyboard.TargetProperty="X"
                                            To="0" />
                        <DoubleAnimation Duration="0"
                                            Storyboard.TargetName="Root"
                                            Storyboard.TargetProperty="Opacity"
                                            To="1" />
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <Border Margin="4,4,-4,-4"
                Background="#052A2E31"
                CornerRadius="5" />
        <Border Margin="3,3,-3,-3"
                Background="#152A2E31"
                CornerRadius="4" />
        <Border Margin="2,2,-2,-2"
                Background="#252A2E31"
                CornerRadius="3" />
        <Border Margin="1,1,-1,-1"
                Background="#352A2E31"
                CornerRadius="2" />
        <Border Background="{StaticResource MetroRedLight}" CornerRadius="2" />
        <Border CornerRadius="2">
            <TextBlock MaxWidth="250"
                       Margin="8,4,8,4"
                       Style="{StaticResource TextBlockStyle_Light}"
                       Text="{Binding (Validation.Errors)[0].ErrorContent}"
                       TextWrapping="Wrap" // here you control the wrapping, so you could do the same on ValidationSummary
                       UseLayoutRounding="false" />
        </Border>
    </Grid>
</ControlTemplate>

希望它有所帮助。