开发者

Silverlight Business Application - Navigation / Styling within the app

More curious than anything, b开发者_开发问答ut I'm wondering if anybody knows why this the scrollviewer in this template is configured in this way:

  <!-- Page ScrollViewer Style -->
<Style x:Key="PageScrollViewerStyle" TargetType="ScrollViewer">
    <Setter Property="BorderBrush" Value="Transparent"/>
    <Setter Property="BorderThickness" Value="0,1,0,1"/>
    <Setter Property="Margin" Value="-58,-5,-58,-5"/>
    <Setter Property="Padding" Value="35,-10,33,-10"/>
    <Setter Property="VerticalScrollBarVisibility" Value="Auto"/>
    <Setter Property="HorizontalScrollBarVisibility" Value="Auto"/>

In particular I'm wondering about the Margin, and Padding attributes. What is is being accomplished here, rather than just allow the ScrollViewer to be contained within the parent object?


Take it out and see what happens.

There isn't a good reason to do that in a style because it will apply to all ScrollViewer controls implicitly. I have noticed, however, that ScrollViewers in Silverlight have strange presentation behavior. Sometimes the scrollbar portion will draw outside and over the parent container. I've had to pad the margins of a ScrollViewer before because of this very reason. The content of the viewer will be correctly framed in the parent but the scroll bars themselves will overflow the right edge.

Anyway, if you remove it and everything looks fine, leave it out.


From MSDN:

Negative values for margin dimensions are permitted, but should be used with caution (and be aware that negative margins can be interpreted differently by different class layout implementations). Negative margins typically clip the content of the object in that direction.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜