0

我正在开发一个跨平台 Xamarin.Forms 应用程序。现在,我通过 Uno Platform 添加了对 WebAssembly 的实验性支持。

在 Uno 平台中,WebAssembly UI 依赖于 UWP UI。正如您在底部看到的,我的 ContentPage 上有一个按钮,它响应大小的变化,不要错过当前的提议:

在此处输入图像描述

在此处输入图像描述

但是,在 WebAssembly 中,按钮的文本会向右移动,如您所见:

在此处输入图像描述 在此处输入图像描述

我在 ScrollView 和 StackLayout 中的特殊 ContentView 项目组合如下:

            <Grid x:Name="ResultGrid" Grid.Row="1">
                <StackLayout>
                    <ScrollView x:Name="Scroller" >
                        <StackLayout x:Name="DataStack" Margin="30" />
<!-- Contentview added inside DataStack via code . -->
                    </ScrollView>
                </StackLayout>

            </Grid>

我的内容视图:

<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             x:Class="ACM_SearchEngine_xFormsWASM.UserControls.SearchResultCapsule" >
  <ContentView.Content>
        <Grid x:Name="ResultDataViewer" Margin="0,10">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <Frame BackgroundColor="#4CB8C282" BorderColor="#343434" CornerRadius="10" Grid.RowSpan="2" Grid.ColumnSpan="3"></Frame>
            <Image x:Name="FileLogo" Margin="10" Source="Assets\journalcover_small.png" Grid.RowSpan="2" Grid.ColumnSpan="1" WidthRequest="96" HeightRequest="96" />
            <Button x:Name="Buy_Button" Text="Satın Al" FontAttributes="Bold" TextColor="#e2e2e2" BackgroundColor="#2A52BE" FontFamily="Segoe UI" Grid.Column="2" Grid.ColumnSpan="1" Grid.RowSpan="1"  CornerRadius="5"  VerticalOptions="Start" HorizontalOptions="Center" FontSize="15.667" Grid.Row="0" Margin="0,10,10,0" WidthRequest="100" />
            <Label x:Name="Issue_TitleMonthYear_Label" FontSize="18.667" FontAttributes="Bold" FontFamily="Segoe UI Bold" Grid.Column="1" Grid.ColumnSpan="1" Grid.RowSpan="1" Margin="10"></Label>
            <Label x:Name="IssueNumber_Label" Text="1" FontSize="18.667" FontAttributes="Bold" FontFamily="Segoe UI Bold" Grid.RowSpan="2" Grid.ColumnSpan="1" VerticalOptions="Center" HorizontalOptions="Center" VerticalTextAlignment="Center" HorizontalTextAlignment="Center" Margin="0,8,0,0" ></Label>
            <Label x:Name="ArticlesList_Label" TextType="Html" Margin="10" Grid.Column="1" Grid.ColumnSpan="1" Grid.Row="1" Grid.RowSpan="1" FontSize="15.667" TextColor="#36454F" FontFamily="Segoe UI Bold" FontAttributes="Italic"  />
        </Grid>
    </ContentView.Content>
</ContentView>

添加代码块是:

 private void ContentPage_Appearing(object sender, EventArgs e)
        {
            SearchKeyword_Title.Text = string.Format("'{0}'  anahtar kelimesi arama sonuçları:", search_keyword);


            var z = new SearchCapsule_IssueCreator(32, SearchCapsule_IssueCreator.Months.Eylül.ToString(), SearchCapsule_IssueCreator.Months.Ekim.ToString(), 2020, "");

            var t = new SearchCapsule_IssueCreator(21, SearchCapsule_IssueCreator.Months.Nisan.ToString(), SearchCapsule_IssueCreator.Months.Mayıs.ToString(), 2020, "");

            z.AddArticle("XAML - HTML dönüşümü nasıl yapılır ?", 15, 20);
            z.AddArticle("Bu bir test yazısıdır.", 45, 60);

            t.AddArticle("UNO Platform Hakkında.", 3, 10);
            t.AddArticle("Deneme 1-2-3.", 22, 30);

            var x = new SearchResultCapsule(z);

            var y = new SearchResultCapsule(t);

            DataStack.Children.Add(x);
            DataStack.Children.Add(y);

        }

我怎样才能防止这个问题?谢谢你。

4

0 回答 0