dcsimg
Results 1 to 2 of 2

Thread: View box and responsive screen

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2014
    Posts
    169

    View box and responsive screen

    Hello friends

    I used viewbox with wpf window to make windows responsive with all screen resolution I find this code in C# corner

    the code works great with any screen resolution

    I want to check the code and give me your opinion because I don't believe that I find the answer for all screen resolution

    here the code shortcut code


    Code:
    <Viewbox VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Stretch="Fill">

    Code:
    <Viewbox VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Stretch="Fill">
            <Grid  >
                <Grid.ColumnDefinitions>
    
                    <ColumnDefinition Width="75*"/>
                    <ColumnDefinition Width="77*"/>
                </Grid.ColumnDefinitions>
    
                <TabControl x:Name="TabResturantItem" HorizontalAlignment="Left" Height="726" Margin="10,10,0,0" VerticalAlignment="Top" Width="681" TabStripPlacement="Bottom" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="{x:Null}" >
                    <TabItem Header="TabItem"  Height="0" Background="{x:Null}">
                        <Grid  >
                            <Button x:Name="button1" Content="صنف 1" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="118,184,0,0" FontSize="25"/>
                            
                            <Button x:Name="button01" Content="صنف 1" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="358,130,0,0" FontSize="25"/>
    
                            <Button x:Name="button06" Content="صنف 1" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="466,246,0,0" FontSize="25"/>
    
                            <Button x:Name="button2" Content="صنف 2" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="30,59,0,0"   FontSize="25"/>
                            
                            
                            <Button x:Name="button02" Content="صنف 2" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="249,5,0,0"  FontSize="25"/>
    
                            <Button x:Name="button3" Content="صنف 3" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="192,300,0,0" FontSize="25"/>
    
                            <Button x:Name="button4" Content="صنف 4" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="319,422,0,0" FontSize="25"/>
                            
                            <Button x:Name="button03" Content="صنف 4" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="118,482,0,0"  FontSize="25"/>
                            
                            <Button x:Name="button04" Content="صنف 4" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="10,368,0,0"  FontSize="25"/>
    
                            <Button x:Name="button5" Content=" 5 صنف" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="438,536,0,0"  FontSize="25"/>
                            
                            <Button x:Name="button05" Content=" 5 صنف" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="227,574,0,0"  FontSize="25"/>
                        </Grid>
                    </TabItem>
                    <TabItem Header="TabItem"  Height="0" Background="{x:Null}">
                        <Grid >
                            <Button x:Name="button6" Content="صنف 1" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="386,154,0,0" Style="{DynamicResource InsdieTab}" FontSize="25"/>
    
                            <Button x:Name="button7" Content="صنف 2" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="508,37,0,0"  Style="{DynamicResource InsdieTab}" FontSize="25"/>
    
                            <Button x:Name="button8" Content="صنف 3" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="132,280,0,0" Style="{DynamicResource InsdieTab}" FontSize="25"/>
    
                            <Button x:Name="button9" Content="صنف 4" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="319,422,0,0" Style="{DynamicResource InsdieTab}" FontSize="25"/>
    
                            <Button x:Name="button10" Content=" 5 صنف" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="438,536,0,0" Style="{DynamicResource InsdieTab}" FontSize="25"/>
                        </Grid>
                    </TabItem>
                    <TabItem Header="TabItem" Height="0" Background="{x:Null}" >
                        <Grid >
                            <Button x:Name="button11" Content="صنف 1" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="118,184,0,0" Style="{DynamicResource InsdieTab}" FontSize="25"/>
    
                            <Button x:Name="button12" Content="صنف 2" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="388,101,0,0"  Style="{DynamicResource InsdieTab}" FontSize="25"/>
    
                            <Button x:Name="button13" Content="صنف 3" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="192,300,0,0" Style="{DynamicResource InsdieTab}" FontSize="25"/>
    
                            <Button x:Name="button14" Content="صنف 4" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="319,422,0,0" Style="{DynamicResource InsdieTab}" FontSize="25"/>
    
                            <Button x:Name="button15" Content=" 5 صنف" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="483,217,0,0" Style="{DynamicResource InsdieTab}" FontSize="25"/>
                        </Grid>
                    </TabItem>
    
                    <TabItem Header="TabItem" Height="0" Background="{x:Null}">
                        <Grid >
                            <Button x:Name="button16" Content="صنف 1" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="438,10,0,0" Style="{DynamicResource InsdieTab}" FontSize="25"/>
    
                            <Button x:Name="button17" Content="صنف 2" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="30,59,0,0"  Style="{DynamicResource InsdieTab}" FontSize="25"/>
    
                            <Button x:Name="button18" Content="صنف 3" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="30,422,0,0" Style="{DynamicResource InsdieTab}" FontSize="25"/>
    
                            <Button x:Name="button19" Content="صنف 4" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="438,400,0,0" Style="{DynamicResource InsdieTab}" FontSize="25"/>
    
                            <Button x:Name="button20" Content=" 5 صنف" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="274,245,0,0" Style="{DynamicResource InsdieTab}" FontSize="25"/>
                        </Grid>
                    </TabItem>
                    <TabItem Header="TabItem" Height="0" Background="{x:Null}">
                        <Grid />
                    </TabItem>
                    <TabItem Header="TabItem" Height="0" Background="{x:Null}">
                        <Grid >
                            <Button x:Name="button21" Content="صنف 1" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="118,184,0,0"  FontSize="25"/>
    
                            <Button x:Name="button22" Content="صنف 2" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="30,59,0,0"   FontSize="25"/>
    
                            <Button x:Name="button23" Content="صنف 3" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="192,300,0,0" FontSize="25"/>
    
                            <Button x:Name="button24" Content="صنف 4" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="319,422,0,0" FontSize="25"/>
    
                            <Button x:Name="button25" Content=" 5 صنف" HorizontalAlignment="Left" VerticalAlignment="Top" Width="157" Height="87" Margin="438,536,0,0"  FontSize="25"/>
                        </Grid>
                    </TabItem>
                    <TabItem Header="TabItem" Height="0" Background="{x:Null}">
                        <Grid />
                    </TabItem>
                    <TabItem Header="TabItem" Height="0" Background="{x:Null}">
                        <Grid />
                    </TabItem>
                </TabControl>
    
    
    
    
    
                <Button x:Name="btnInterfacebttom1" HorizontalAlignment="Left" Height="97" Margin="4,735,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource Interfacebutton2}" Content="لحوم&#xa;سوري" FontSize="24" Click="btnInterfacebttom1_Click" />
                <Button x:Name="btnInterfacebttom2" HorizontalAlignment="Left" Height="97" Margin="103,735,0,0" VerticalAlignment="Top" Width="100" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource Interfacebutton1}" Content="لحوم&#xa;باتيبان" FontSize="24" Click="btnInterfacebttom2_Click"/>
                <Button x:Name="btnInterfacebttom3" HorizontalAlignment="Left" Height="97" Margin="202,735,0,0" VerticalAlignment="Top" Width="97" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource Interfacebutton2}" Content="لحوم&#xa;كيزر" FontSize="24" Click="btnInterfacebttom3_Click" />
                <Button x:Name="btnInterfacebttom4" HorizontalAlignment="Left" Height="97" Margin="302,735,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource Interfacebutton3}" Content="لحوم&#xa;شامي" FontSize="24" Click="btnInterfacebttom4_Click" />
                <Button x:Name="btnInterfacebttom5" HorizontalAlignment="Left" Height="97" Margin="401,735,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource Interfacebutton2}" Content="لحوم&#xa;سوري" FontSize="24" />
                <Button x:Name="btnInterfacebttom6" HorizontalAlignment="Left" Height="97" Margin="500,735,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource Interfacebutton1}" Content="شعبي&#xa;سوري" FontSize="24" />
                <Button x:Name="btnInterfacebttom7" HorizontalAlignment="Left" Height="97" Margin="597,735,0,0" VerticalAlignment="Top" Width="97" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource Interfacebutton2}" Content="شعبي&#xa;باتيبان" FontSize="24" />
                <Button x:Name="btnInterfacebttom8" HorizontalAlignment="Left" Height="97" Margin="696,735,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource Interfacebutton3}" Content="شعبي&#xa;كيزر" FontSize="24" />
    
    
    
    
                <Button x:Name="btnVerticalColumn11" HorizontalAlignment="Left" Height="83" Margin="702,8,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource InterVertica2}" Content="شعبي&#xA;كيزر" FontSize="24" Grid.ColumnSpan="2" />
                <Button x:Name="btnVerticalColumn12" HorizontalAlignment="Left" Height="83" Margin="702,94,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource InterVertical}" Content="شعبي&#xA;كيزر" FontSize="24" Grid.ColumnSpan="2" />
                <Button x:Name="btnVerticalColumn13" HorizontalAlignment="Left" Height="82" Margin="702,182,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource InterVertica2}" Content="شعبي&#xA;كيزر" FontSize="24" Grid.ColumnSpan="2" />
                <Button x:Name="btnVerticalColumn14" HorizontalAlignment="Left" Height="82" Margin="702,268,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource InterVertical}" Content="شعبي&#xA;كيزر" FontSize="24" Grid.ColumnSpan="2" />
                <Button x:Name="btnVerticalColumn15" HorizontalAlignment="Left" Height="83" Margin="702,354,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource InterVertica2}" Content="شعبي&#xA;كيزر" FontSize="24" Grid.ColumnSpan="2" />
                <Button x:Name="btnVerticalColumn16" HorizontalAlignment="Left" Height="83" Margin="702,441,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource InterVertical}" Content="علب" FontSize="24" Grid.ColumnSpan="2" />
                <Button x:Name="btnVerticalColumn17" HorizontalAlignment="Left" Height="82" Margin="702,528,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource InterVertica2}" Content="وجبات" FontSize="24" Grid.ColumnSpan="2" />
                <Button x:Name="btnVerticalColumn18" HorizontalAlignment="Left" Height="97" Margin="702,615,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource InterVertical}" Content="كريب" FontSize="24" Grid.ColumnSpan="2" />
                <Rectangle Grid.Column="1" HorizontalAlignment="Left" Height="822" Margin="10,10,0,0" VerticalAlignment="Top" Width="794"/>
                <Button x:Name="calcbutton0" HorizontalAlignment="Left" Height="83" Margin="484,459,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource CalcButton}" Content="0" FontSize="24" Grid.Column="1" />
                <Button x:Name="calcbutton1" HorizontalAlignment="Left" Height="83" Margin="364,459,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource CalcButton}" Content="1" FontSize="24" Grid.Column="1" />
                <Button x:Name="calcbutton2" HorizontalAlignment="Left" Height="83" Margin="251,459,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource CalcButton}" Content="2" FontSize="24" Grid.Column="1" />
                <Button x:Name="calcbutton3" HorizontalAlignment="Left" Height="83" Margin="484,549,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource CalcButton}" Content="3" FontSize="24" Grid.Column="1" />
                <Button x:Name="calcbutton4" HorizontalAlignment="Left" Height="83" Margin="364,549,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource CalcButton}" Content="4" FontSize="24" Grid.Column="1" />
                <Button x:Name="calcbutton5" HorizontalAlignment="Left" Height="83" Margin="251,549,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource CalcButton}" Content="5" FontSize="24" Grid.Column="1" />
                <Button x:Name="calcbutton6" HorizontalAlignment="Left" Height="83" Margin="484,637,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource CalcButton}" Content="6" FontSize="24" Grid.Column="1" />
                <Button x:Name="calcbutton7" HorizontalAlignment="Left" Height="83" Margin="364,637,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource CalcButton}" Content="7" FontSize="24" Grid.Column="1" />
                <Button x:Name="calcbutton8" HorizontalAlignment="Left" Height="83" Margin="251,637,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource CalcButton}" Content="8" FontSize="24" Grid.Column="1" />
                <Button x:Name="calcbutton9" HorizontalAlignment="Left" Height="83" Margin="251,725,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource CalcButton}" Content="9" FontSize="24" Grid.Column="1" />
                <Button x:Name="calcbutton00" HorizontalAlignment="Left" Height="83" Margin="364,725,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource CalcButton}" Content="00" FontSize="24" Grid.Column="1" />
                <Button x:Name="calcbuttonfraction" HorizontalAlignment="Left" Height="83" Margin="484,725,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource CalcButton}" Content="." FontSize="24" Grid.Column="1" />
                
                <Button x:Name="calcbuttonleft1" HorizontalAlignment="Left" Height="83" Margin="610,459,0,0" VerticalAlignment="Top" Width="184" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource CalcButtonleft}" Content="فتح" FontSize="24" Grid.Column="1" />
                <Button x:Name="calcbuttonleft2" HorizontalAlignment="Left" Height="83" Margin="610,549,0,0" VerticalAlignment="Top" Width="184" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource CalcButtonleft}" Content="درج" FontSize="24" Grid.Column="1" />
                <Button x:Name="calcbuttonleft3" HorizontalAlignment="Left" Height="83" Margin="610,637,0,0" VerticalAlignment="Top" Width="184" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource CalcButtonleft}" Content="مراجع" FontSize="24" Grid.Column="1" />
                <Button x:Name="calcbuttonleft5" HorizontalAlignment="Left" Height="83" Margin="610,725,0,0" VerticalAlignment="Top" Width="184" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource CalcButtonleft}" Content="الجورنال" FontSize="24" Grid.Column="1" />
                
                <ListBox x:Name="listBox" Grid.Column="1" HorizontalAlignment="Left" Height="254" Margin="33,10,0,0" VerticalAlignment="Top" Width="761"/>
    
                <TextBox x:Name="txtTotal" Grid.Column="1" HorizontalAlignment="Left" Height="84" Margin="33,364,0,0" TextWrapping="Wrap" Text="0.00" VerticalAlignment="Top" Width="761" Background="#FFF1F3C5" FontSize="35"/>
                <TextBox x:Name="txtSubTotal" Grid.Column="1" HorizontalAlignment="Left" Height="84" Margin="33,270,0,0" TextWrapping="Wrap" Text="0.00" VerticalAlignment="Top" Width="761" Background="#FFB2AFAF" FontSize="35"/>
                <Button x:Name="CASH" HorizontalAlignment="Left" Height="171" Margin="33,637,0,0" VerticalAlignment="Top" Width="201" BorderThickness="1,1,3,3" Opacity="0.99" Content="CASH" FontSize="24" Grid.Column="1" RenderTransformOrigin="-1.734,0.359" Background="#FFDE6B6B" Click="CASH_Click"  />
                <Button x:Name="CalcTop1" HorizontalAlignment="Left" Height="83" Margin="33,549,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource CalcButton}" Content="توصيل" FontSize="24" Grid.Column="1" />
                <Button x:Name="CalcTop2" HorizontalAlignment="Left" Height="83" Margin="138,549,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource CalcButton}" Content="S.TOT" FontSize="24" Grid.Column="1" />
                <Button x:Name="CalcTop3" HorizontalAlignment="Left" Height="83" Margin="33,461,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource CalcButton}" Content="طعمية" FontSize="24" Grid.Column="1" />
                <Button x:Name="CalcTop4" HorizontalAlignment="Left" Height="83" Margin="134,459,0,0" VerticalAlignment="Top" Width="96" BorderThickness="1,1,3,3" Opacity="0.99" Style="{StaticResource CalcButton}" Content="فول" FontSize="24" Grid.Column="1" />
            </Grid>
        </Viewbox>

  2. #2
    Junior Member
    Join Date
    Jan 2020
    Posts
    27

    Re: View box and responsive screen

    I checked your code it can be work as expected for all the resolutions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width