1

我有带功能区选项卡和数据网格的主翼。当窗口最大化以适应屏幕时,如何最大化窗口中的所有内容?我正在尝试使用视图框,但它不起作用。

<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>

我尝试在网格标签之前添加

帮助。

提前致谢

4

2 回答 2

1

添加StretchDirection="Both"到您的 ViewBox,它应该可以工作

// Will Stretch it and keep the ratio the same
<Viewbox Stretch="Uniform" StretchDirection="Both">


// Will Stretch it to fill full screen regardless of ratio
<Viewbox Stretch="Fill" StretchDirection="Both">
于 2011-05-20T14:45:46.517 回答
0

我只是要出去猜测您需要将视图框锚定到控件的侧面。这是边距属性。

ViewBox应该有一些看起来像Margin=5,5,5,5XAML 的东西。

于 2011-05-20T14:28:37.103 回答