【解決方法】WPFウィンドウをレスポンシブする方法は?

[ad_1]

I tried a lot but I can't get it to be responsive please help me get it to be responsive

私が試したこと:

This is my code for WPF(XAML):-

XML
<Window x:Class="Display3DModel.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:helix="http://helix-toolkit.org/wpf"
        xmlns:display3dmodel ="clr-namespace:Display3DModel"
        xmlns:hx="http://helix-toolkit.org/wpf/SharpDX" xmlns:helix1="http://schemas.microsoft.com/netfx/2009/xaml/presentation"
        xmlns:syncfusion="http://schemas.syncfusion.com/wpf"
        WindowStartupLocation="CenterScreen"
        Title="M-Crafter 125" Height="795.2" Width="1190" HorizontalAlignment="Left" VerticalAlignment="Top" >

    <Window.Resources>
        <display3dmodel:BoundsConverter x:Key="BoundsConverter"></display3dmodel:BoundsConverter>
    </Window.Resources>


    <Grid RenderTransformOrigin="0.5,0.5" >
        <Grid.RowDefinitions>
            <RowDefinition Height="46*"/>
            <RowDefinition Height="661*"/>
            <RowDefinition Height="42*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="110*"/>
            <ColumnDefinition Width="734*"/>
            <ColumnDefinition Width="287*"/>
        </Grid.ColumnDefinitions>



        <StackPanel x:Name="optionpanel" HorizontalAlignment="Left" Margin="0,47,0,0.4" VerticalAlignment="Center" Width="111"  
         Height="675" Background="#FFE2DFDF" Orientation="Vertical" Grid.RowSpan="2" RenderTransformOrigin="0.466,0.425" >
             <Button x:Name="Object_placement" Content="Object placement" Margin="6,10,0,0" HorizontalAlignment="Left" 
               VerticalAlignment="Top" Width="98" Height="46" RenderTransformOrigin="0.451,1.224" BorderBrush="Black" FontWeight="Bold" 
               FontSize="10" Grid.ColumnSpan="2" Click="Object_placement_Click"/>
            <Button x:Name="Print_Setting" Content="Print Setting" Margin="6,5,1,0" HorizontalAlignment="Left" VerticalAlignment="Top" 
               Width="98" RenderTransformOrigin="-0.309,1.083" Height="46" FontSize="10" FontWeight="Bold" BorderBrush="Black" 
               Grid.ColumnSpan="2" Click="Print_Setting_Click"/>
            <Button x:Name="Manual_Control" Content="Manual Control" Margin="6,5,-0.4,0" HorizontalAlignment="Left" 
               VerticalAlignment="Top" Width="98" Height="46" FontSize="10" FontWeight="Bold" BorderBrush="Black" Grid.ColumnSpan="2" 
               Click="Manual_Control_Click"/>
            <Button x:Name="Machine_Setting" Content="Machine Setting" Margin="6,5,0,0" HorizontalAlignment="Left" 
               VerticalAlignment="Top" Width="98" BorderBrush="Black" Height="52" FontSize="10" FontWeight="Bold" Grid.ColumnSpan="2" 
               Click="Machine_Setting_Click"/>
            <Button Content="delete" Height="20" Margin="10,10,10.2,0" Click="Button_Click"/>
            <Button Content="hide/show" Height="20" Margin="10,10,10.2,0" Click="Button_Click_1"/>
            <Button Content="Color" Height="26" Margin="10,15,10.2,0" Click="Button_Click_3" RenderTransformOrigin="0.5,0.504"/>
            <Button Content="ADD" Height="48" Margin="10,10,10.2,0" Click="Button_Click_4"/>
        </StackPanel>


        <StackPanel x:Name="settingpanel" HorizontalAlignment="Left" Height="675" Margin="767.8,47,0,0.581" VerticalAlignment="center" 
        Width="301" Background="#FFE2DFDF" Grid.Column="1" Orientation="Vertical" Grid.ColumnSpan="2" Grid.RowSpan="2">
        </StackPanel>

        <StackPanel x:Name="footerpanel" HorizontalAlignment="Left" Margin="0,5.6,-33,-0.4" Width="1217" Background="#FFE2DFDF" 
        Grid.ColumnSpan="3" Orientation="Vertical"  Grid.Row="2">
            <TextBlock x:Name="Xvaluetxt" Text="" Height="34" Margin="1053,0,101.8,0" />
            <TextBlock x:Name="Yvaluetxt" Text="" Height="38" Margin="1120,-33,41.8,0" />
            <Label Content="Print Progress:" Margin="10,-40,1117.8,0" Height="27"/>
            <ProgressBar Height="20" Margin="132,-40,883.8,0"/>
        </StackPanel>



        <StackPanel x:Name="headerpanel" HorizontalAlignment="Left" Height="42" VerticalAlignment="Top" Width="1217" 
        Background="#FF656565" Grid.ColumnSpan="3"  Orientation="Vertical" Margin="0,0,-33,0">

            <Button x:Name="connectbtn" Content="" HorizontalAlignment="Left" Margin="493,3,0,0" VerticalAlignment="Top" Width="40" 
               Height="35" RenderTransformOrigin="0.5,0.5" BorderBrush="White" BorderThickness="2" Grid.Column="1" 
               Click="connectbtn_Click"/>
            <Button x:Name="loadbtn" Content="" HorizontalAlignment="Center" Margin="538,-35,637.8,10" VerticalAlignment="Top" Width="40" 
               Height="35" RenderTransformOrigin="0.5,0.5" BorderBrush="White" BorderThickness="2" Grid.Column="1" 
               Click="loadbtn_Click"/>
            <Button x:Name="startstopbtn" HorizontalAlignment="Center" Margin="584,-46,592.8,10" VerticalAlignment="Top" Width="40" 
               Height="36" RenderTransformOrigin="-0.185,0.52" Grid.Column="1" BorderThickness="2"  BorderBrush="White" 
               Click="startstopbtn_Click"/>
            <Button x:Name="stopbtn" Stylus.IsFlicksEnabled="False" Content="" HorizontalAlignment="Right" Margin="0,-46,547.8,10" 
               VerticalAlignment="Top" Width="40" Height="36" BorderBrush="Black"  BorderThickness="3"  
               RenderTransformOrigin="0.542,0.689" Grid.Column="1"/>
            <Button x:Name="emergencybtn" Content="EMERGENCY STOP" HorizontalAlignment="Right" Margin="0,-44,44.8,10" 
               VerticalAlignment="Top" Width="126" Height="34" BorderBrush="#FFADADAD" Background="#FFDD0505" Foreground="White" 
               FontWeight="Bold" Grid.Column="2"/>
        </StackPanel>



        <StackPanel x:Name="viewerPanel" Grid.Column="1" HorizontalAlignment="Left" Height="675" Margin="0.8,47,0,0.581" 
          VerticalAlignment="Center" Width="767" Orientation="Vertical" Grid.RowSpan="2">
            <TabControl x:Name="viewtab" HorizontalAlignment="Left" Height="673" Margin="1,2.6,0,0" VerticalAlignment="Top" Width="766" 
              Grid.Column="1" Grid.Row="1" Grid.RowSpan="2">
                <TabItem Header="3D View" Margin="0,-2,-11.8,-0.2">
                    <Grid Background="#FFE5E5E5" Margin="0,0,0.4,0.4">
                    </Grid>
                </TabItem>
                <TabItem Header="Layer View" Margin="12.8,-2,-13,0" HorizontalAlignment="Left" Width="73">
                    <Grid>
                    </Grid>
                </TabItem>
            </TabControl>
        </StackPanel>

解決策 1

要素 (コントロール) でこれを行わないでください。

Width="98" Height="46"

コンテナーに制御させます (例: Grid)あなたのために仕事をしてください。

[ad_2]

コメント

タイトルとURLをコピーしました