本人初学WPF,现在编写了一个UserControl,如何让这个控件自适应加载窗体的宽度和高度适应不同分辨率显示 5
<GridBackground="#FF444444"MaxHeight="900"SnapsToDevicePixels="True"Width="300"><Grid...
<Grid Background="#FF444444" MaxHeight="900" SnapsToDevicePixels="True" Width="300">
<Grid.RowDefinitions>
<RowDefinition Height="31.99"/>
<RowDefinition Height="30.01"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Margin="0">
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF8F8F8F" Offset="0.204"/>
<GradientStop Color="#FF2B2A2A" Offset="0.996"/>
</LinearGradientBrush>
</Grid.Background>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="32"/>
<ColumnDefinition Width="0.909*"/>
</Grid.ColumnDefinitions>
<Image x:Name="imgUserFace" Margin="0" Height="Auto" Width="Auto" Grid.Column="0" HorizontalAlignment="Stretch">
<Image.BitmapEffect>
<DropShadowBitmapEffect/>
</Image.BitmapEffect>
</Image>
<Label x:Name="WelcomeLab" Margin="4,0,-4,0" FontFamily="黑体" FontSize="16" Content="数字矿山三维地测信息系统" Grid.Column="1" Foreground="Snow"/>
<Rectangle Margin="0" RenderTransformOrigin="1,0.5" Height="15" VerticalAlignment="Bottom" Grid.Column="1">
<Rectangle.Fill>
<VisualBrush Visual="{Binding ElementName=WelcomeLab}"/>
</Rectangle.Fill>
<Rectangle.OpacityMask>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0.1" Color="Transparent"/>
<GradientStop Offset="1" Color="#44000000"/>
</LinearGradientBrush>
</Rectangle.OpacityMask>
<Rectangle.RenderTransform>
<ScaleTransform ScaleY="-1"/>
</Rectangle.RenderTransform>
</Rectangle>
</Grid>
<StackPanel Orientation="Horizontal" Background="#FFBDBDBD" Margin="0,-0.25,0,0" Grid.Row="1">
<Button x:Name="btnAddMap" Height="30" Margin="0" Style="{DynamicResource ToolBarButton}" Width="30" Background="#FF77EBE3" FontSize="9.333" ToolTip="加载数据" Click="btnAddMap_Click">
<Image x:Name="imgAddMap" Width="25" Height="25" Margin="0" RenderTransformOrigin="0.5,0.5" VerticalAlignment="Top">
<Image.BitmapEffect>
<DropShadowBitmapEffect/>
</Image.BitmapEffect>
</Image>
</Button>
</StackPanel>
<StackPanel VerticalAlignment="Top" Grid.Row="2" Height="0"/>
</Grid>
我去掉了width和height但是没有用啊 结果引用的对象挤成了一团,没有设置高度和宽度的话,貌似是按照对象的内容来自动填充高宽的,我如何绑定到引用这个控件的WINDOW或PAGE上,随着WINDOW或PAGE的高度宽度自动充满呢? 展开
<Grid.RowDefinitions>
<RowDefinition Height="31.99"/>
<RowDefinition Height="30.01"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Margin="0">
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF8F8F8F" Offset="0.204"/>
<GradientStop Color="#FF2B2A2A" Offset="0.996"/>
</LinearGradientBrush>
</Grid.Background>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="32"/>
<ColumnDefinition Width="0.909*"/>
</Grid.ColumnDefinitions>
<Image x:Name="imgUserFace" Margin="0" Height="Auto" Width="Auto" Grid.Column="0" HorizontalAlignment="Stretch">
<Image.BitmapEffect>
<DropShadowBitmapEffect/>
</Image.BitmapEffect>
</Image>
<Label x:Name="WelcomeLab" Margin="4,0,-4,0" FontFamily="黑体" FontSize="16" Content="数字矿山三维地测信息系统" Grid.Column="1" Foreground="Snow"/>
<Rectangle Margin="0" RenderTransformOrigin="1,0.5" Height="15" VerticalAlignment="Bottom" Grid.Column="1">
<Rectangle.Fill>
<VisualBrush Visual="{Binding ElementName=WelcomeLab}"/>
</Rectangle.Fill>
<Rectangle.OpacityMask>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0.1" Color="Transparent"/>
<GradientStop Offset="1" Color="#44000000"/>
</LinearGradientBrush>
</Rectangle.OpacityMask>
<Rectangle.RenderTransform>
<ScaleTransform ScaleY="-1"/>
</Rectangle.RenderTransform>
</Rectangle>
</Grid>
<StackPanel Orientation="Horizontal" Background="#FFBDBDBD" Margin="0,-0.25,0,0" Grid.Row="1">
<Button x:Name="btnAddMap" Height="30" Margin="0" Style="{DynamicResource ToolBarButton}" Width="30" Background="#FF77EBE3" FontSize="9.333" ToolTip="加载数据" Click="btnAddMap_Click">
<Image x:Name="imgAddMap" Width="25" Height="25" Margin="0" RenderTransformOrigin="0.5,0.5" VerticalAlignment="Top">
<Image.BitmapEffect>
<DropShadowBitmapEffect/>
</Image.BitmapEffect>
</Image>
</Button>
</StackPanel>
<StackPanel VerticalAlignment="Top" Grid.Row="2" Height="0"/>
</Grid>
我去掉了width和height但是没有用啊 结果引用的对象挤成了一团,没有设置高度和宽度的话,貌似是按照对象的内容来自动填充高宽的,我如何绑定到引用这个控件的WINDOW或PAGE上,随着WINDOW或PAGE的高度宽度自动充满呢? 展开
3个回答
展开全部
喂喂,别误导啊,wcf是wcf,wpf是wpf,winform是winform,不要混为一谈,winform都出了10几年了,winform和wpf唯一的共同点就是同为windows应用程序的解决方案,而wpf只不过是winform的新生替代物而已,而wcf则是与wpf、wf随着.netframework3.0一起发布的,只是.netframework3.0的组成部分,和winform都不靠边。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
将其中涉及到width和height都去掉
追问
我去掉了width和height但是没有用啊 结果引用的对象挤成了一团,没有设置高度和宽度的话,貌似是按照对象的内容来自动填充高宽的,我如何绑定到引用这个控件的WINDOW或PAGE上,随着WINDOW或PAGE的高度宽度自动充满呢?
追答
简单做的话你都用Grid布局即可,StackPanel布局就是挤在一起的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
对齐方式调成两端对齐
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询