如何使我的给定WPF XAML ListView响应所有屏幕分辨率?

时间:2017-11-30 00:08:24

标签: wpf xaml listview visual-studio-2017 responsive

我想让我的列表视图响应。它适用于1920 x 1080(这是我的屏幕),但是从屏幕上消失,当我尝试在另一个不同大小的屏幕上显示时,会出现滚动条以查看文本的其余部分。我尝试了很多方法,但每当我改变屏幕尺寸时,显示器变得很糟糕。谁能告诉我以下列表视图代码有什么问题?

<Grid Grid.Column="1" Grid.RowSpan="2" Margin="0"  >
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
             <ListBox ItemsSource="{Binding Receipts}" Grid.Row="0"
                      Background="Transparent"
                      HorizontalAlignment="Center"     HorizontalContentAlignment="Stretch"
                      BorderBrush="Transparent"  BorderThickness="0"
                      ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                      ItemContainerStyle="{StaticResource TransparentListBoxItemStyle}">
                <ListBox.ItemTemplate>
                    <DataTemplate>

                        <Grid Background="#202020" Margin="10,0,10,0" Height="Auto" Width="Auto">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition  Width="Auto" />
                                <ColumnDefinition Width="Auto"/>


                            </Grid.ColumnDefinitions>

                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />


                            </Grid.RowDefinitions>
                            <Grid Margin="0"  Grid.Column="0">
                                <Grid.Background > 
                                    <ImageBrush ImageSource="pack://application:,,,/Resources/pickup-no-orange.png" />
                                </Grid.Background>
                                <Viewbox   Stretch="Uniform"  Width="150pt" Height="120pt" >
                                    <TextBlock Text="{Binding ReceiptNum}" 
                                           HorizontalAlignment="Stretch"    VerticalAlignment="Stretch"
                                            FontFamily="Reboto Reqular"
                                           Foreground="White"
                                           Margin="0" />
                                </Viewbox>
                            </Grid>
                            <Grid Margin="0"  Grid.Column="1">
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="Auto" />
                                </Grid.RowDefinitions>
                                <Viewbox   Grid.Row="0" Stretch="Uniform"  Width="130pt" Height="30pt" >
                                    <TextBlock  Margin="0"    FontFamily="Reboto Light" Text="PICKUP" FontSize="30pt"   
                                           Foreground="White"/>
                                </Viewbox>
                                <Viewbox   Grid.Row="1" Stretch="Uniform"  Width="150pt" Height="50pt" >
                                    <TextBlock  Margin="0,0,0,40"  Foreground="{StaticResource ReceiptTextBrushWhite}"   FontSize="60pt" FontFamily="Reboto Light"                               
                                     >
                                        <Run Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type windows:BaseView}},  Path=DataContext.CollectFromName}"/>
                                         <Run Text="{Binding CollectFrom}"/>                                             
                                    </TextBlock>

                                </Viewbox>
                            </Grid>
                        </Grid>

                    </DataTemplate>

                </ListBox.ItemTemplate>
            </ListBox>

            <!-- this button is used as part of the close sequence. it appers in top right of screen -->


            <Button Grid.Row="1"                         
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Stretch"
                    Command="{Binding CloseSequenceCmd}"
                    Style="{StaticResource FullyTransparentButtonStyle}"
                    CommandParameter="3" >

                <Image    
                 Source="pack://application:,,,/Resources/powered-by-PR-orange.png"
                 Stretch="Uniform"   Width="200"
                 HorizontalAlignment="Center"
                 VerticalAlignment="Center"
                 Margin="5"                     
                 />
            </Button>
        </Grid>

0 个答案:

没有答案