避免转换成高度时剪切(支持不同的分辨率)

时间:2018-09-09 09:00:07

标签: wpf

我正在制作一个应用程序,其中使用了“网格面板”中的一些控件。它的工作正常,但对于不同的屏幕分辨率存在问题。网格控件无法适应屏幕分辨率,也无法裁剪某些“高度”控件。宽度正确地适应了屏幕分辨率。如您所见,将前后图像转换为高度时,会导致剪切问题。该如何解决?

在转换为高度之前: enter image description here

翻译成高度后: enter image description here

代码:

 <Grid Grid.Row="3">
                <Grid.Background>
                    <SolidColorBrush Color="#FF3E7038" Opacity="0.3"/>
                </Grid.Background>

                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition Width="1*"/>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition Width="2*"/>
                </Grid.ColumnDefinitions>



                <TextBlock Text="Customer:" Grid.Column="0" Margin="10"/>
                <controls:AutoCompleteBox Margin="0,10,10,0" Name="CustomerSearch" IsTextCompletionEnabled="True" SelectedItem="{Binding Name, Mode=TwoWay}" Grid.Column="1" PreviewKeyDown="CustomerSearch_PreviewKeyDown" >
                    <controls:AutoCompleteBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="{Binding Code}"/>
                                <TextBlock Text="{Binding Name}"/>
                                <TextBlock Text="{Binding Address}"/>
                                <TextBlock Text="{Binding Contact}"/>
                            </StackPanel>
                        </DataTemplate>
                    </controls:AutoCompleteBox.ItemTemplate>
                </controls:AutoCompleteBox>

                <TextBlock Text="Gross Amount:" Grid.Column="2" VerticalAlignment="Center" />
                <TextBox Margin="5,10,0,0"  Name="GrossAmount" Text="0.0" Grid.Column="3" IsReadOnly="True"/>

                <TextBlock Text="Discount%:" Grid.Column="2" Grid.Row="1"/>
                <TextBox Name="Discount" Text="0.0" Grid.Column="3" Grid.Row="1" PreviewTextInput="Discount_PreviewTextInput" PreviewKeyDown="Discount_PreviewKeyDown" />

                <TextBlock Text="Net Pay:" Grid.Column="2" Grid.Row="2"/>
                <TextBox Name="NetPay" Text="0.0" Grid.Column="3" Grid.Row="2" PreviewTextInput="Discount_PreviewTextInput" PreviewKeyDown="Discount_PreviewKeyDown" />

                <TextBlock Text="Paid:" Grid.Column="2" Grid.Row="3"/>
                <TextBox Name="Paid" Text="0.0" Grid.Column="3" Grid.Row="3" PreviewTextInput="Paid_PreviewTextInput" PreviewKeyDown="Paid_PreviewKeyDown"/>

                <TextBlock Text="Return:" Grid.Column="2" Grid.Row="4"/>
                <TextBox Name="Return" Text="0.0" Grid.Column="3" Grid.Row="4" IsReadOnly="True"/>

                <WrapPanel Grid.Row="5" Margin="0,10,0,0" Grid.ColumnSpan="5" Grid.Column="2">
                    <Button Name="CheckoutBtn"  Margin="0,0,5,0" PreviewKeyDown="CheckoutBtn_PreviewKeyDown" Click="CheckoutBtn_Click" >
                        <StackPanel Orientation="Horizontal">
                            <Image Width="40" Height="40" Stretch="Uniform" Source="/Images/checkout.png"/>
                            <Label Content="CHECKOUT" />
                        </StackPanel>
                    </Button>
                    <Button Name="CancelBtn"  Margin="0,0,5,0"  Click="CancelBtn_Click" >
                        <StackPanel Orientation="Horizontal">
                            <Image Width="40" Height="40" Stretch="Uniform" Source="/Images/cancel.png"/>
                            <Label Content="CANCEL" />
                        </StackPanel>
                    </Button>

                    <Button Name="SaveBtn"  Click="SaveBtn_Click" Margin="0,0,5,0">
                        <StackPanel Orientation="Horizontal">
                            <Image Width="40" Height="40" Stretch="Uniform" Source="/Images/save.png"/>
                            <Label Content="SAVE" />
                        </StackPanel>
                    </Button>


                </WrapPanel>

            </Grid>

0 个答案:

没有答案