Laden...

Fenster wird auf kleinerem Bildschirm abgeschnitten

Erstellt von R3turnz vor 7 Jahren Letzter Beitrag vor 7 Jahren 2.038 Views
R
R3turnz Themenstarter:in
125 Beiträge seit 2016
vor 7 Jahren
Fenster wird auf kleinerem Bildschirm abgeschnitten

Hallo,
das Fenster ist ohne Canvas und fast ohne explizite Angaben von Width und Height erstellt. Auf einem größeren Bildschirm ist auch alles wie gewollt angezeigt, auf einem kleinen Notebook wird aber ein Teil abgeschnitten. Bisher dachte ich WPF ist Auflösungsunabhänig. Die eingestellte Mindestgröße müsste doch auf dem kleinen Bildschirm herunterskaliert werden... Wieso kann das nicht so sein?

16.842 Beiträge seit 2008
vor 7 Jahren

Ich hoffe Dir ist klar, dass ohne Beispiel die Leute hier wenig helfen können.
Du musst bedenken, dass wir Deinen Monitor nicht sehen....

Nirgends steht, dass WPF automatisch Auflösungsunabhängig ist.
Der Unterschied ist vor allem, dass WPF mit einer Basis arbeitet, die nicht auf Pixel basieren (sondern auf einer unabhängigen Basis, die 1/96 Inch entspricht).
Ebenso sind alle grafischen Elemente von Haus aus Vektoren, was das Skalieren halt einfacher macht.

Wenn Du es schlecht/suboptimal umsetzt, dann ist WPF genauso anfällig für eine fehlerhafte Skalierung wie jede andere UI-Technologie.

5.658 Beiträge seit 2006
vor 7 Jahren

Hi R3turnz,

das Fenster ist ohne Canvas und fast ohne explizite Angaben von Width und Height erstellt.

Was genau meinst du mit "fast ohne"? Entweder hast du Angaben gemacht, oder du hast die Default-Werte benutzt. Aber wie machst du "fast keine" Angaben?

Bisher dachte ich WPF ist Auflösungsunabhänig. Die eingestellte Mindestgröße müsste doch auf dem kleinen Bildschirm herunterskaliert werden... Wieso kann das nicht so sein?

Die Basics zum Layout von WPF werden in The Layout System beschrieben.

Weeks of programming can save you hours of planning

R
R3turnz Themenstarter:in
125 Beiträge seit 2016
vor 7 Jahren

@MrSparkle

Was genau meinst du mit "fast ohne"? Entweder hast du Angaben gemacht, oder du hast die Default-Werte benutzt. Aber wie machst du "fast keine" Angaben?

Ich skaliere nur einige Icons und Bilder auf einheitliche Größen.

Hier der gekürzte Code:

<metro:MetroWindow
    x:Class="OpenWeather.GUI.Views.MainWindow"
    <!-- ... -->
    Title="{x:Static properties:Resources.Title}" MinHeight="750" Height="750" MinWidth="600" Width="600"
    RightWindowCommandsOverlayBehavior="HiddenTitleBar">
    <metro:MetroWindow.Resources>
        <BooleanToVisibilityConverter x:Key="BoolToVisibiltyConverter" />
        <converters:EnumLocalizationConverter x:Key="EnumLocalizationConverter" />
    </metro:MetroWindow.Resources>
    <!-- Flyouts und Event Bindings -->
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="3*" />
            <RowDefinition Height="3*" />
        </Grid.RowDefinitions>
        <ProgressBar IsIndeterminate="True"
                     Visibility="{Binding IsBusy, Converter={StaticResource BoolToVisibiltyConverter}}" Height="20" />
        <TextBlock DataContext="{Binding Location}" FontSize="20" Grid.Row="1">
            <TextBlock.Text>
                <MultiBinding StringFormat="{}{0},{1}" FallbackValue="-,-">
                    <Binding Path="City" FallbackValue="-" />
                    <Binding Path="Region.DisplayName" FallbackValue="-" />
                </MultiBinding>
            </TextBlock.Text>
        </TextBlock>
        <DockPanel DataContext="{Binding CurrentWeather.Weather}" Grid.Row="2">
            <TextBlock DockPanel.Dock="Right" Text="{Binding TempUnit}"
                       Margin="10" />
            <TextBlock DockPanel.Dock="Left"
                       Text="{Binding Temperature, FallbackValue='-'}"
                       FontSize="30" />
        </DockPanel>
        <DockPanel Grid.Row="3">
            <Image DockPanel.Dock="Left" Source="{Binding CurrentWeather.Icon}" Height="75" Width="75"
                   Stretch="Uniform" />
            <TextBlock DockPanel.Dock="Right" DataContext="{Binding CurrentWeather.Weather}" TextAlignment="Left"
                       FontSize="20">
                <TextBlock.Text>
                    <MultiBinding StringFormat="{}{0} ({1})" FallbackValue="- (-)">
                        <Binding Path="Condition" Converter="{StaticResource EnumLocalizationConverter}" />
                        <Binding Path="Description" />
                    </MultiBinding>
                </TextBlock.Text>
            </TextBlock>
        </DockPanel>
        <Grid DataContext="{Binding SunCycle}" Grid.Row="4">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                <Path Fill="Black" Height="25" Width="25"
                      Data="" />
                <TextBlock Text="{x:Static properties:Resources.Sunrise}" />
            </StackPanel>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Column="1">
                <Path Fill="Black" Height="25" Width="25"
                      Data="" />
                <TextBlock Text="{x:Static properties:Resources.Sunset}" />
            </StackPanel>
            <TextBlock Text="{Binding Sunrise.TimeOfDay}" Grid.Row="1" />
            <TextBlock Text="{Binding Sunset.TimeOfDay}" Grid.Row="1" Grid.Column="1" />
        </Grid>
        <Grid DataContext="{Binding CurrentWeather.Weather}" Grid.Row="5">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                <Path Fill="" />
                <TextBlock Text="{x:Static properties:Resources.Humidity}" />
            </StackPanel>

            <TextBlock Grid.Row="1" Text="{Binding Humidity, FallbackValue='-', StringFormat={}{0} %}" FontSize="20" />
            <TextBlock Grid.Column="1" Text="{x:Static properties:Resources.Pressure}" />
            <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Pressure,FallbackValue='-', StringFormat={}{0} hPa}"
                       FontSize="20" />
            <StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Center">
                <Path Fill="Black" Height="25" Width="25"
                      Data="" />
                <TextBlock Text="{x:Static properties:Resources.WindSpeed}" />
            </StackPanel>
            <TextBlock Grid.Column="2" Grid.Row="1"
                       Text="{Binding WindSpeed,FallbackValue='-', StringFormat={}{0} meter/sec}" FontSize="20" />
        </Grid>
        <ListBox ItemsSource="{Binding DailyForecast}"
                 SelectedItem="{Binding SelectedForecastDay, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged}"
                 Grid.Row="6">
        <!-- ... -->
        </ListBox>
        <ListBox ItemsSource="{Binding HourlyForecastAtSelectedDay}" Grid.Row="7">
        <!-- ... -->
        </ListBox>
    </Grid>
</metro:MetroWindow>

F
10.010 Beiträge seit 2004
vor 7 Jahren

Du sagst doch das MinWith und Height 750 sind, was ist da jetzt verwunderlich?