1

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

CPM
  • 855
  • 3
  • 12
  • 14
  • I would suggest posting a sample of your xaml code to get a better and more specific answer – Joel Briggs May 20 '11 at 14:21
  • 1
    Can you post your XAML code with the ViewBox? – Rachel May 20 '11 at 14:57
  • @Rachel Pls have a look to my code with the question it has been edited. – CPM May 20 '11 at 15:08
  • @Rachel and @msarchet when I add Viewbox Stretch="UniformToFill" Margin="5,5,5,5" It is stretching everything However my columns dissapear and I just have my 1st column on my grid. – CPM May 20 '11 at 15:21

2 Answers2

1

Add StretchDirection="Both" to your ViewBox and it should work

// 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">
Rachel
  • 130,264
  • 66
  • 304
  • 490
  • yeah is stretching but want font to get bigger and the entire grid and tab to get bigger so If I project this in bigger screen looks bigger. I hope you are understanding what i am saying.How can I do that. Thank you for your reply – CPM May 20 '11 at 14:53
  • Not working when I try to do that my all window get condensed in a line. – CPM May 20 '11 at 15:52
  • I have got my problem solved, was because on my DataGridTextColumn I had Widht "1*" changed to fixed one. Thanks for your help. – CPM May 20 '11 at 16:02
0

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 like Margin=5,5,5,5 in it's XAML.

msarchet
  • 15,104
  • 2
  • 43
  • 66
  • Sorry I dont understand what you are saying – CPM May 20 '11 at 14:38
  • @Rachel and @msarchet when I add Viewbox Stretch="UniformToFill" Margin="5,5,5,5" It is stretching everything However my columns dissapear and I just have my 1st column on my grid. – CPM May 20 '11 at 15:14