<Style x:Key="GradIEntPanel" targettype="ContentControl"> <Setter Property="Template"> <Setter.Value> <ControlTemplate targettype="ContentControl"> <GrID HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"> <Rectangle RadiusY="10" RadiusX="10" stroke="Black" strokeThickness="0"> <Rectangle.Effect> <DropShadowEffect Opacity="0.56" ShadowDepth="1" BlurRadius="3" /> </Rectangle.Effect> <Rectangle.Fill> <linearGradIEntBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradIEntStop color="#FFE1EAF3"/> <GradIEntStop color="White" Offset="1"/> <GradIEntStop color="#FFFAFBFD" Offset="1"/> </linearGradIEntBrush> </Rectangle.Fill> </Rectangle> <ContentPresenter margin="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/> </GrID> </ControlTemplate> </Setter.Value> </Setter></Style>
…
之前(工作正常):
<border Style="{StaticResource SearchContainerborder}" > <GrID margin="5"> <GrID.RowDeFinitions> <RowDeFinition /> </GrID.RowDeFinitions> <GrID.ColumnDeFinitions> <ColumnDeFinition WIDth="*" /> <ColumnDeFinition WIDth="auto" /> </GrID.ColumnDeFinitions> <Togglebutton Style="{StaticResource TogglebuttonExpanderStyle}" GrID.Row="0" GrID.Column="1" Height="25" WIDth ="25" HorizontalAlignment="Center" VerticalAlignment="top" /> <ContentControl GrID.Row="0" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/> </GrID></border>
之后(用ContentControl替换border):
<ContentControl Style="{StaticResource GradPanel}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <GrID margin="5"> <GrID.RowDeFinitions> <RowDeFinition /> </GrID.RowDeFinitions> <GrID.ColumnDeFinitions> <ColumnDeFinition WIDth="*" /> <ColumnDeFinition WIDth="auto" /> </GrID.ColumnDeFinitions> <Togglebutton Style="{StaticResource TogglebuttonExpanderStyle}" GrID.Row="0" GrID.Column="1" Height="25" WIDth ="25" HorizontalAlignment="Center" VerticalAlignment="top" /> <ContentControl GrID.Row="0" HorizontalContentAlignment="Stretch" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/> </GrID></ContentControl>解决方法 您需要在外部ContentControl上设置HorizontalContentAlignment =“Stretch”和VerticalContentAlignment =“Stretch”设置.
默认行为是不拉伸容器的内容.
例如第一行应该是:
<ContentControl Style="{StaticResource GradPanel}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" >总结
以上是内存溢出为你收集整理的内容控件内容大小填写Silverlight 4全部内容,希望文章能够帮你解决内容控件内容大小填写Silverlight 4所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)