当 wpf 中窗口最大化时,如何拉伸窗口中的所有内容?
我的主窗口带有功能区选项卡和数据网格。当窗口最大化以适合屏幕时,如何最大化窗口中的所有内容?我正在尝试使用视图框,但它不起作用。
<Viewbox Stretch="Uniform">
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<ribbon:Ribbon x:Name="Ribbon">
<ribbon:RibbonTab x:Name="HomeTab"
Header="Home">
<ribbon:RibbonGroup x:Name="Group1"
Header="Refresh">
<ribbon:RibbonButton x:Name="BtmRefresh"
LargeImageSource="Images\refresh.png"
Label="Refresh" Margin="25,0,30,0" Click="BtmRefresh_Click" />
</ribbon:RibbonGroup>
</ribbon:RibbonTab>
</ribbon:Ribbon>
<StackPanel Name="PanelDataGrid" Height="Auto" >
<DataGrid AutoGenerateColumns="False" Margin="0,138,0,0" Name="dataGrid" Height="Auto" ItemsSource="{Binding}" SelectionUnit="Cell" AlternatingRowBackground="#FFDFE9F5"
SelectionMode="Single" ColumnWidth="68" HeadersVisibility="Column" RowBackground="{x:Null}" >
<DataGrid.Background>
<ImageBrush ImageSource="/GridCellColor;component/Images/barcode.png" />
</DataGrid.Background>
<DataGrid.Columns >
<DataGridTextColumn Binding="{Binding Path=Job_Num}" Header="Job Nº" IsReadOnly="True" Width="1*" />
<DataGridTextColumn Binding="{Binding Path=Product_Code}" IsReadOnly="True" Header="Product" Width="1*" />
</DataGrid.Columns>
</DataGrid>
</StackPanel>
</Grid>
</Viewbox>
我尝试在网格标签
帮助之前添加。
提前致谢
I have got my main wingow with ribbon tabs and a datagrid. How can I maximize everythin in the window when window is maximized to fit the screen?I am trying to use viewbox but its not working.
<Viewbox Stretch="Uniform">
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<ribbon:Ribbon x:Name="Ribbon">
<ribbon:RibbonTab x:Name="HomeTab"
Header="Home">
<ribbon:RibbonGroup x:Name="Group1"
Header="Refresh">
<ribbon:RibbonButton x:Name="BtmRefresh"
LargeImageSource="Images\refresh.png"
Label="Refresh" Margin="25,0,30,0" Click="BtmRefresh_Click" />
</ribbon:RibbonGroup>
</ribbon:RibbonTab>
</ribbon:Ribbon>
<StackPanel Name="PanelDataGrid" Height="Auto" >
<DataGrid AutoGenerateColumns="False" Margin="0,138,0,0" Name="dataGrid" Height="Auto" ItemsSource="{Binding}" SelectionUnit="Cell" AlternatingRowBackground="#FFDFE9F5"
SelectionMode="Single" ColumnWidth="68" HeadersVisibility="Column" RowBackground="{x:Null}" >
<DataGrid.Background>
<ImageBrush ImageSource="/GridCellColor;component/Images/barcode.png" />
</DataGrid.Background>
<DataGrid.Columns >
<DataGridTextColumn Binding="{Binding Path=Job_Num}" Header="Job Nº" IsReadOnly="True" Width="1*" />
<DataGridTextColumn Binding="{Binding Path=Product_Code}" IsReadOnly="True" Header="Product" Width="1*" />
</DataGrid.Columns>
</DataGrid>
</StackPanel>
</Grid>
</Viewbox>
And I tried adding before grid tag
Help.
Thanks in Advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将
StretchDirection="Both"
添加到您的 ViewBox 中,它应该可以工作Add
StretchDirection="Both"
to your ViewBox and it should work我只是要出去猜测您需要将视图框锚定到控件的侧面。这是保证金属性。
您的
ViewBox
的 XAML 中应该有类似于Margin=5,5,5,5
的内容。I'm just going to go out and guess that you need to anchor your viewbox to the sides of the control. This is the margin property.
Your
ViewBox
should have something that looks likeMargin=5,5,5,5
in it's XAML.