XAML UNO Windows和WASM渲染不一致

7uzetpgm  于 2023-09-28  发布在  Windows
关注(0)|答案(1)|浏览(122)

在我的UNO跨平台应用程序中,在Windows UI Desktop和WASM之间呈现xaml的方式存在差异。
以下是Windows UI桌面渲染:

在WASM渲染中,时间拾取器丢失:

代码如下所示:

<ListView Name="scheduleList" ItemsSource="{x:Bind VM.Schedules}" SelectedItem="{x:Bind VM.SelectedSchedule}"
     Header="Scheduled Appearances:" SelectionMode="Single" >
    <ListView.ItemTemplate>
        <DataTemplate x:DataType="data:Schedule">
            <Grid Margin="4">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <StackPanel Orientation="Horizontal" Grid.Row="0">
                     <CalendarDatePicker x:Name="locDate"  Header="Location Date:"  HorizontalAlignment="Stretch"
                            PlaceholderText="Location Date" Date="{Binding LocationOffsetDate, Mode=TwoWay}" 
                             DateFormat = "{}{dayofweek.full},{month.full} {day.integer}, {year.full}"/>
                    <CheckBox x:Name="okToDelete" Content="Can Delete" IsChecked="{Binding Selected,Mode=TwoWay}"
                               Margin="10,0,0,0" FontSize="18"/>
                </StackPanel>

                <StackPanel Orientation="Horizontal" Grid.Row="1" >
                    <TimePicker x:Name="stTime" Header="Start Time" SelectedTime="{Binding StartTime, Mode=TwoWay}" MinuteIncrement="15"/>
                    <TimePicker x:Name="enTime" Header="End Time" SelectedTime="{Binding EndTime, Mode=TwoWay}" MinuteIncrement="15"/>
                </StackPanel>
            </Grid>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

在第二个示例中,Windows在字段中显示数据:

但在WASM中,数据缺失:

代码看起来像这样:

<StackPanel Grid.Row="3" x:Name="editLocation" Margin="0,4" HorizontalAlignment="Stretch">
    <TextBlock x:Name="createNewLocation" Text="Define a new location" FontSize="18" Foreground="{StaticResource NavigatorBkgColor}"
               HorizontalAlignment="Center" />
    <controls:FTNTextBox Description="Location Name:"  IsRequired="true"
           InputValue="{x:Bind VM.SelectedLocationClone.Name, Mode=TwoWay}" />
    <controls:FTNTextBox Description="Location Address, include city:"  IsRequired="true"
           InputValue="{x:Bind VM.SelectedLocationClone.Address, Mode=TwoWay}" />
    <controls:FTNTextBox Description="Zip code"  IsRequired="true"
           InputValue="{x:Bind VM.SelectedLocationClone.Postal, Mode=TwoWay}" />
    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
        <Button x:Name="addLocation" Content="Add Location" Margin="10,0,10,0"  
                Command="{x:Bind VM.InsertLocationCommand}"/>
        <Button x:Name="updateChanges" Content="Update Changes" Margin="10,0,5,0" 
                Command="{x:Bind VM.UpdateLocationCommand}"/>
        <Button x:Name="deleteLocation" Content="Delete Location" Margin="5,0,10,0" 
                Command="{x:Bind VM.DeleteLocationCommand}"/>
    </StackPanel>
</StackPanel>

FTNTTextBox看起来像:

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
        <!-- This column takes all available horizontal space -->
        <ColumnDefinition Width="Auto" />
        <!-- This column adjusts to fit its content -->
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
<!-- Description Label -->

    <TextBlock Grid.Row="0" Grid.Column="0" x:Name="descriptionBlock" Text="{x:Bind Description}" 
            Style="{StaticResource FTN_TextBoxDescriptionStyle}" 
            VerticalAlignment="Bottom" HorizontalAlignment="Left"  />
    <TextBlock Grid.Row="0" Grid.Column="1" x:Name="requiredBlock" Text="*required" 
            Style="{StaticResource FTN_TextRquiredStyle}"
            VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="0,0,10,0" />             
    
    <!-- Input TextBox -->
    <TextBox Grid.Row="1" Grid.ColumnSpan="2" x:Name="inputTextBox" 
             TextChanged="OnTextChanged"  Text="{x:Bind InputValue, Mode=TwoWay}"
             Style="{StaticResource FTN_TextInputStyle}" Margin="10,0,10,10" />
</Grid>

我想看看是否有什么可以解决这些分歧,但没有发现任何东西。我会很感激你对这件事的任何想法。我还没找到办法让它工作。

pxq42qpu

pxq42qpu1#

我认为有两个问题。显然,WASM不支持TimerPicker(至少我的结论是这样)。第二个问题具有约束力。我想我的页面混合了Binding和x:Bind,这一定引起了一些混乱。

相关问题