AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-3149673

Prescott Chartier's questions

Martin Hope
Prescott Chartier
Asked: 2025-03-07 03:36:58 +0800 CST

Maui App 连接到 Visual Studio 时以调试模式运行,但独立运行时崩溃

  • 5

我已将问题缩小到Flyout菜单 xaml 代码中的某个部分,但无法查明原因。我的 xaml:

        <VerticalStackLayout
            x:Name="Flyout"
            WidthRequest="260"
            HorizontalOptions="Start"
            Spacing="2"
            Grid.Row="1"
            BackgroundColor="Gold"
            TranslationX="-250">
            <HorizontalStackLayout HorizontalOptions="Start" HeightRequest="50" >
                <Image Source="addEmployee.jpg" Style="{StaticResource IconLabelStyle}" />
                <Label x:Name="AddEmployee" Text="Add Employee" Style="{StaticResource LabelStyle}" />
                <HorizontalStackLayout.GestureRecognizers>
                    <TapGestureRecognizer Tapped="OnMenuItemTap" CommandParameter="Add Another Participant"/>
                </HorizontalStackLayout.GestureRecognizers>
            </HorizontalStackLayout>
            <HorizontalStackLayout HorizontalOptions="Start" HeightRequest="50">
                <Image Source="assign.jpg" Style="{StaticResource IconLabelStyle}" />
                <Label x:Name="Assign" Text="Assign Employee To Section" Style="{StaticResource LabelStyle}" />
                <HorizontalStackLayout.GestureRecognizers>
                    <TapGestureRecognizer Tapped="OnMenuItemTap" CommandParameter="Re-Register"/>
                </HorizontalStackLayout.GestureRecognizers>
            </HorizontalStackLayout>
            <HorizontalStackLayout HorizontalOptions="Start" HeightRequest="50">
                <Image Source="text.jpg" Style="{StaticResource IconLabelStyle}" />
                <Label x:Name="sendtext" Text="Send Text" Style="{StaticResource LabelStyle}" />
                <HorizontalStackLayout.GestureRecognizers>
                    <TapGestureRecognizer Tapped="OnMenuItemTap" CommandParameter="ChatRoom"/>
                </HorizontalStackLayout.GestureRecognizers>
            </HorizontalStackLayout>
            <HorizontalStackLayout HorizontalOptions="Start" HeightRequest="50">
                <Image Source="myaccount.jpg" Style="{StaticResource IconLabelStyle}" />
                <Label x:Name="MyAccount" Text="My Account" Style="{StaticResource LabelStyle}" />
                <HorizontalStackLayout.GestureRecognizers>
                    <TapGestureRecognizer Tapped="OnMenuItemTap" CommandParameter="My Account"/>
                </HorizontalStackLayout.GestureRecognizers>
            </HorizontalStackLayout>
            <HorizontalStackLayout HorizontalOptions="Start" HeightRequest="50">
                <Image Source="myaccount.jpg" Style="{StaticResource IconLabelStyle}" />
                <Label x:Name="LogOut" Text="Log Off" Style="{StaticResource LabelStyle}" />
                <HorizontalStackLayout.GestureRecognizers>
                    <TapGestureRecognizer Tapped="OnMenuItemTap" CommandParameter="Log Off"/>
                </HorizontalStackLayout.GestureRecognizers>
            </HorizontalStackLayout>
        </VerticalStackLayout>

当我注释掉Flyout代码时,应用程序将在调试器之外运行。我转储了测试设备崩溃日志,在其中发现了以下内容:

03-05 20:52:00.570 10573  4825  4825 I MonoDroid: UNHANDLED EXCEPTION:
03-05 20:52:00.575 10573  4825  4825 I MonoDroid: Android.Runtime.JavaProxyThrowable: Exception of type 'Android.Runtime.JavaProxyThrowable' was thrown.
03-05 20:52:00.575 10573  4825  4825 I MonoDroid: 
03-05 20:52:00.575 10573  4825  4825 I MonoDroid:   --- End of managed Android.Runtime.JavaProxyThrowable stack trace ---
03-05 20:52:00.575 10573  4825  4825 I MonoDroid: android.runtime.JavaProxyThrowable: [System.InvalidCastException]: Specified cast is not valid.
03-05 20:52:00.575 10573  4825  4825 I MonoDroid:   at Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.SetPropertyValue + 0xb9(Unknown Source)
03-05 20:52:00.575 10573  4825  4825 I MonoDroid:   at Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.Visit + 0xf6(Unknown Source)
03-05 20:52:00.575 10573  4825  4825 I MonoDroid:   at Microsoft.Maui.Controls.Xaml.ElementNode.Accept + 0x90(Unknown Source)
03-05 20:52:00.575 10573  4825  4825 I MonoDroid:   at Microsoft.Maui.Controls.Xaml.ElementNode.Accept + 0x3e(Unknown Source)
03-05 20:52:00.575 10573  4825  4825 I MonoDroid:   at Microsoft.Maui.Controls.Xaml.ElementNode.Accept + 0x67(Unknown Source)
03-05 20:52:00.575 10573  4825  4825 I MonoDroid:   at Microsoft.Maui.Controls.Xaml.ElementNode.Accept + 0x67(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at Microsoft.Maui.Controls.Xaml.ElementNode.Accept + 0x67(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at Microsoft.Maui.Controls.Xaml.ElementNode.Accept + 0x67(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at Microsoft.Maui.Controls.Xaml.RootNode.Accept + 0x81(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at Microsoft.Maui.Controls.Xaml.XamlLoader.Visit + 0x97(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at Microsoft.Maui.Controls.Xaml.XamlLoader.Load + 0x9d(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at Microsoft.Maui.Controls.Xaml.XamlLoader.Load + 0x0(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at Microsoft.Maui.Controls.Xaml.XamlLoader.Load + 0x29(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at Microsoft.Maui.Controls.Xaml.Extensions.LoadFromXaml + 0x0(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at MyApp.RegUser.InitializeComponent + 0x1(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at MyApp.RegUser..ctor + 0xa0(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at MyApp.Logon+<SignOn>d__6.MoveNext + 0x7b6(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw + 0x11(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess + 0x37(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification + 0x2d(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd + 0x8(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at System.Runtime.CompilerServices.TaskAwaiter.GetResult + 0x0(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at MyApp.Logon+<<OnCounterClicked>b__5_0>d.MoveNext + 0x73(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw + 0x11(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess + 0x37(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification + 0x2d(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd + 0x8(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at System.Runtime.CompilerServices.TaskAwaiter.GetResult + 0x0(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at MyApp.Logon+<OnCounterClicked>d__5.MoveNext + 0xf4(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw + 0x11(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at System.Threading.Tasks.Task+<>c.<ThrowAsync>b__128_0 + 0x0(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 + 0x0(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at Java.Lang.Thread+RunnableImplementor.Run + 0x8(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at Java.Lang.IRunnableInvoker.n_Run + 0x0(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V + 0x5(Unknown Source)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at mono.java.lang.RunnableImplementor.n_run(Native Method)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:29)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at android.os.Handler.handleCallback(Handler.java:958)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at android.os.Handler.dispatchMessage(Handler.java:99)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at android.os.Looper.loopOnce(Looper.java:230)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at android.os.Looper.loop(Looper.java:319)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at android.app.ActivityThread.main(ActivityThread.java:9063)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at java.lang.reflect.Method.invoke(Native Method)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:588)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
03-05 20:52:00.576 10573  4825  4825 I MonoDroid: 
03-05 20:52:00.576 10573  4825  4825 I MonoDroid:   --- End of managed Android.Runtime.JavaProxyThrowable stack trace ---

此行出现错误Specified cast is not valid. at Microsoft.Maui.Controls.Xaml.ApplyPropertiesVisitor.SetPropertyValue + 0xb9(Unknown Source)

我没有在其中看到任何可以确定演员异常的信息。也许另一双眼睛可以找到。

maui
  • 1 个回答
  • 28 Views
Martin Hope
Prescott Chartier
Asked: 2025-03-06 11:09:48 +0800 CST

Maui 网格中的列显示为堆叠的,而不是位于同一行

  • 5

我以编程方式操作网格,根据数据集中的行数在后台代码中设置行数和列数。我在网格的列中显示图像、标签和按钮。我正在处理的数据集有 2 行,因此我在网格中创建了 1 行和 2 列。我将控件添加到VerticalStacklayout指定行和列的网格行中。但是网格显示时列是堆叠的。到目前为止,我尝试过的所有方法都没有效果。我在页面上还定义了一个弹出菜单,它运行良好。我的 xaml:

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MyApp.DeptUser"
             x:DataType="Line"
             Title="DeptUser">
    <ContentPage.Resources>
        <ResourceDictionary>
            <Style x:Key="IconLabelStyle" TargetType="Label">
                <Setter Property="FontSize" Value="Medium" />
                <Setter Property="WidthRequest" Value="50" />
                <Setter Property="VerticalTextAlignment" Value="Center" />
                <Setter Property="HorizontalTextAlignment" Value="Center" />
                <Setter Property="TextColor" Value="Black" />
                <Setter Property="BackgroundColor" Value="Gold" />
            </Style>
            <Style x:Key="LabelStyle" TargetType="Label">
                <Setter Property="VerticalTextAlignment" Value="Center" />
                <Setter Property="Padding" Value="5,5" />
                <Setter Property="FontSize" Value="Medium" />
                <Setter Property="BackgroundColor" Value="Gold" />
            </Style>
        </ResourceDictionary>
    </ContentPage.Resources>
    <ScrollView>
        <Grid
            RowDefinitions="50,*" >
            <VerticalStackLayout
                Grid.Row = "0"
                BackgroundColor="Gold"
            >
                <Button
                Text="☰"
                FontSize="Medium"
                CornerRadius="0"
                HorizontalOptions="Start"
                WidthRequest="50"
                TextColor="Black"
                BackgroundColor="Gold" 
                Clicked="ShowFlyout"/>
            </VerticalStackLayout>
            <VerticalStackLayout
                Grid.Row="1"
                Padding="5,0"
                Spacing="10">
                <Image
                    Source="banner2.jpg"
                    HeightRequest="75"
                    Aspect="AspectFit"
                    SemanticProperties.Description="Company Personnel"
                />

                <Line Stroke="Black" X2="{Binding Width, Source={RelativeSource Self}}" HorizontalOptions="Fill" StrokeThickness="2" />

                <Label x:Name="lblNumberOfPersonnel"
                    Text="Personnel in your department:"
                    Style="{StaticResource Headline}"
                    TextColor="Blue"
                    HorizontalOptions="Center"
                    HeightRequest="25"
                    FontSize="16"
                    SemanticProperties.HeadingLevel="Level1"/>
                <Grid x:Name="MyCurrentEmployees">
                </Grid>
            </VerticalStackLayout>
            <Border
                x:Name="Overlay"
                IsVisible="false"
                Grid.Row="1"
                BackgroundColor="DarkGray"
                Opacity="0.8">
                <Border.GestureRecognizers>
                    <TapGestureRecognizer Tapped="OnOverlayTap"/>
                </Border.GestureRecognizers>
            </Border>
            <VerticalStackLayout
                x:Name="Flyout"
                WidthRequest="260"
                HorizontalOptions="Start"
                Spacing="2"
                Grid.Row="1"
                BackgroundColor="Gold"
                TranslationX="-250">
                <HorizontalStackLayout HorizontalOptions="Start" HeightRequest="50" >
                    <Image Source="addEmployee.jpg" Style="{StaticResource IconLabelStyle}" />
                    <Label x:Name="AddEmployee" Text="Add Employee" Style="{StaticResource LabelStyle}" />
                    <HorizontalStackLayout.GestureRecognizers>
                        <TapGestureRecognizer Tapped="OnMenuItemTap" CommandParameter="Add Another Participant"/>
                    </HorizontalStackLayout.GestureRecognizers>
                </HorizontalStackLayout>
                <HorizontalStackLayout HorizontalOptions="Start" HeightRequest="50">
                    <Image Source="assign.jpg" Style="{StaticResource IconLabelStyle}" />
                    <Label x:Name="Assign" Text="Assign Employee To Section" Style="{StaticResource LabelStyle}" />
                    <HorizontalStackLayout.GestureRecognizers>
                        <TapGestureRecognizer Tapped="OnMenuItemTap" CommandParameter="Re-Register"/>
                    </HorizontalStackLayout.GestureRecognizers>
                </HorizontalStackLayout>
                <HorizontalStackLayout HorizontalOptions="Start" HeightRequest="50">
                    <Image Source="text.jpg" Style="{StaticResource IconLabelStyle}" />
                    <Label x:Name="sendtext" Text="Send Text" Style="{StaticResource LabelStyle}" />
                    <HorizontalStackLayout.GestureRecognizers>
                        <TapGestureRecognizer Tapped="OnMenuItemTap" CommandParameter="ChatRoom"/>
                    </HorizontalStackLayout.GestureRecognizers>
                </HorizontalStackLayout>
                <HorizontalStackLayout HorizontalOptions="Start" HeightRequest="50">
                    <Image Source="myaccount.jpg" Style="{StaticResource IconLabelStyle}" />
                    <Label x:Name="MyAccount" Text="My Account" Style="{StaticResource LabelStyle}" />
                    <HorizontalStackLayout.GestureRecognizers>
                        <TapGestureRecognizer Tapped="OnMenuItemTap" CommandParameter="My Account"/>
                    </HorizontalStackLayout.GestureRecognizers>
                </HorizontalStackLayout>
                <HorizontalStackLayout HorizontalOptions="Start" HeightRequest="50">
                    <Image Source="myaccount.jpg" Style="{StaticResource IconLabelStyle}" />
                    <Label x:Name="LogOut" Text="Log Off" Style="{StaticResource LabelStyle}" />
                    <HorizontalStackLayout.GestureRecognizers>
                        <TapGestureRecognizer Tapped="OnMenuItemTap" CommandParameter="Log Off"/>
                    </HorizontalStackLayout.GestureRecognizers>
                </HorizontalStackLayout>
            </VerticalStackLayout>
        </Grid>
    </ScrollView>
</ContentPage>

我遇到问题的网格是MyCurrentEmployees。我的代码:

protected override async void OnAppearing()
{
    myCurrentemployees = Utils.ToDataSet(myService.GetEmployeeNames(MyUser.Username, MyUser.Password));
    for (int x = 0; x < myCurrentemployees.Tables[0].Rows.Count/2; x+=2)
    {
        MyCurrentEmployees.RowDefinitions.Add(new RowDefinition());
    }

    ColumnDefinition c1 = new ColumnDefinition();
    c1.Width = new GridLength(50, GridUnitType.Star);
    ColumnDefinition c2 = new ColumnDefinition();
    c2.Width = new GridLength(50, GridUnitType.Star);
    MyCurrentEmployees.ColumnDefinitions.Add(c1);
    MyCurrentEmployees.ColumnDefinitions.Add(c2);

    foreach (DataRow MyDataRow in myCurrentemployees.Tables[0].Rows)
    {
        Image Myimage = new Image();
        Myimage.HeightRequest = 150;
        Myimage.WidthRequest = 150;
        byte[] imageArray = new byte[1];

        MyPhotoDataSet = Utils.ToDataSet(myService1.GetPhoto(MyUser.Username, MyUser.Password, MyDataRow["EmployeeID"].ToString()));
        if (MyPhotoDataSet.Tables[0].Rows[0][0].ToString() != null)
        {
            imageArray = (byte[])MyPhotoDataSet.Tables[0].Rows[0][0];
        }
        else
        {
            MyPhotoDataSet = Utils.ToDataSet(myService.GetDummyPhoto(MyUser.Username, MyUser.Password));
            imageArray = (byte[])MyPhotoDataSet.Tables[0].Rows[0][0];
        }
        MemoryStream memory = new MemoryStream(imageArray);
        Myimage.Source = Microsoft.Maui.Controls.ImageSource.FromStream(() => (Stream)memory);
        Label Mylabel = new Label();
        Mylabel.Text = MyDataRow["Name"].ToString();
        Mylabel.HorizontalTextAlignment = TextAlignment.Center;
        Mylabel.WidthRequest = 150;
        Button MyDeleteButton = new Button();
        MyDeleteButton.Text = "Delete Employee";
        MyDeleteButton.TextColor = Colors.Black;
        MyDeleteButton.FontAttributes = FontAttributes.Bold;
        MyDeleteButton.BackgroundColor = Colors.Gold;
        MyDeleteButton.WidthRequest = 150;
        VerticalStackLayout MyLayOut = new VerticalStackLayout();
        MyLayOut.Children.Add(Myimage);
        MyLayOut.Children.Add(Mylabel);
        MyLayOut.Children.Add(MyDeleteButton);
        MyCurrentParticipants.Add(MyLayOut, RowNumber, ColumnNumber);
        if (ColumnNumber == 1)
        {
            ColumnNumber = 0;
            RowNumber++;
        } else
        {
            ColumnNumber++;
        }
    }
}

截屏:

在此处输入图片描述 我做错什么了?

c#
  • 1 个回答
  • 37 Views
Martin Hope
Prescott Chartier
Asked: 2025-02-28 02:35:33 +0800 CST

.Net Maui Android 将输入控件立即对齐到标签右侧

  • 6

我必须定义以下内容页面:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="OrganizeMyLeague.Subscription"
             x:DataType="Line"
             Title="Subscription">
    <VerticalStackLayout
            Padding="5,0"
            Spacing="5">

        <Label Text="Account Information"
            Style="{StaticResource Headline}"
            TextColor="Blue"
            HorizontalOptions="Center"
            SemanticProperties.HeadingLevel="Level1"/>
        
           <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100" />
                <ColumnDefinition Width="250" />
            </Grid.ColumnDefinitions>
                <Label Grid.Row="0" Grid.Column="0" HorizontalTextAlignment="End" VerticalOptions="Center" Text="First Name" FontSize="16" TextColor="Black" HorizontalOptions="Start" />
                <Entry Grid.Row="0" Grid.Column="1" x:Name="txtFirstname" Placeholder="Enter First Name" PlaceholderColor="#C7C7C7" WidthRequest="150" VerticalOptions="Center" FontSize="16" TextColor="Blue" HorizontalOptions="End" />
                <Label Grid.Row="1" Grid.Column="0" HorizontalTextAlignment="End" VerticalOptions="Center" Text="Last Name" FontSize="16" TextColor="Black" HorizontalOptions="Start" />
                <Entry Grid.Row="1" Grid.Column="1" x:Name="txtLasttname" Placeholder="Enter Last Name" PlaceholderColor="#C7C7C7" WidthRequest="150" VerticalOptions="Center" FontSize="16" TextColor="Blue" HorizontalOptions="End" />
                <Label Grid.Row="2" Grid.Column="0" HorizontalTextAlignment="End" VerticalOptions="Center" Text="Address" FontSize="16" TextColor="Black" HorizontalOptions="Start" />
                <Entry Grid.Row="2" Grid.Column="1" x:Name="txtAddress" Placeholder="Enter Address" PlaceholderColor="#C7C7C7" WidthRequest="150" VerticalOptions="Center" FontSize="16" TextColor="Blue" HorizontalOptions="End" />
                <Label Grid.Row="3" Grid.Column="0" HorizontalTextAlignment="End" VerticalOptions="Center" Text="City" FontSize="16" TextColor="Black" HorizontalOptions="Start" />
                <Entry Grid.Row="3" Grid.Column="1" x:Name="txtCity" Placeholder="Enter City" PlaceholderColor="#C7C7C7" WidthRequest="150" VerticalOptions="Center" FontSize="16" TextColor="Blue" HorizontalOptions="End" />
                <Label Grid.Row="4" Grid.Column="0" HorizontalTextAlignment="End"  VerticalOptions="Center" Text="Select State" FontSize="16" TextColor="Black" HorizontalOptions="Start" />
                <Picker Grid.Row="4" Grid.Column="1" x:Name="txtState" WidthRequest="150" VerticalOptions="Center" FontSize="16" TextColor="Blue" HorizontalOptions="End" />
                <Label Grid.Row="5" Grid.Column="0" HorizontalTextAlignment="End" VerticalOptions="Center" Text="Zip Code" FontSize="16" TextColor="Black" HorizontalOptions="Start" />
                <Entry Grid.Row="5" Grid.Column="1" x:Name="txtZipCode" Placeholder="Enter Zip Code" PlaceholderColor="#C7C7C7" WidthRequest="150" VerticalOptions="Center" FontSize="16" TextColor="Blue" HorizontalOptions="End" />
            </Grid>
    </VerticalStackLayout>
</ContentPage>

显示方式如下:

在此处输入图片描述

我无法影响网格中的第二列,无论我做什么,我都无法让该列更靠近标签。我更希望输入控件精确地出现在标签的右侧,但显然没有办法做到这一点。我只能让第二列(第 1 列)更靠近标签文本。

c#
  • 2 个回答
  • 42 Views
Martin Hope
Prescott Chartier
Asked: 2025-02-13 00:50:55 +0800 CST

如何解决“如果指定了 x:DataType,则可以编译绑定以提高运行时性能”警告

  • 5

我有以下页面:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="PhotoManager.MainPage">

    <ScrollView>
        <VerticalStackLayout
            Padding="5,0"
            Spacing="10">
            <Image
                Source="banner2.jpg"
                HeightRequest="75"
                Aspect="AspectFit"
                SemanticProperties.Description="Organize My League" />
            
                <Line Stroke="Black" X2="{Binding Width, Source={RelativeSource Self}}" HorizontalOptions="Fill" StrokeThickness="2" />

            <ActivityIndicator x:Name="activityIndicator"
                       IsVisible="false"
                       IsRunning="True"
                       Color="{StaticResource NavigationBarColor}" ZIndex="1000"
                       VerticalOptions="Center" HorizontalOptions="Center"
                       WidthRequest="100" HeightRequest="100"/>
            <Label
                Text="Log On"
                Style="{StaticResource Headline}"
                SemanticProperties.HeadingLevel="Level1" />

            <Label
                Text="Username"
                Style="{StaticResource SubHeadline}"
                SemanticProperties.HeadingLevel="Level2"
                SemanticProperties.Description="Enter your username." />

            <Entry x:Name="TheUsername"
                Placeholder="Enter Username"/>

            <Label
                Text="Password"
                Style="{StaticResource SubHeadline}"
                SemanticProperties.HeadingLevel="Level2"
                SemanticProperties.Description="Enter your password." />

            <Entry x:Name="ThePassword"
                Placeholder="Enter Password"
                IsPassword="true" />

            <Button
                x:Name="CounterBtn"
                Text="Submit" 
                SemanticProperties.Hint="Log on"
                Clicked="OnCounterClicked"
                HorizontalOptions="Fill" />

        </VerticalStackLayout>
    </ScrollView>
</ContentPage>

以下行:

<Line Stroke="Black" X2="{Binding Width, Source={RelativeSource Self}}" HorizontalOptions="Fill" StrokeThickness="2" />

生成主题警告。如何解决该警告?

c#
  • 1 个回答
  • 42 Views
Martin Hope
Prescott Chartier
Asked: 2025-01-01 02:54:49 +0800 CST

单击复选框时获取单击框列表中复选框的数据值

  • 5

我看到了很多方法可以循环并检索选中的复选框的值,我需要在复选框列表中选中复选框时立即使用复选框值启动一个过程。不确定是否可行,但如果可行就好了。否则,我必须创建一个极其复杂且低效的程序来检查所有复选框及其与系统中值的关系,我想避免这种情况。到目前为止,我的代码:

我将数据绑定到后台代码中的复选框列表:

首先我从数据库中获取数据:

MyDataSet = GetItems(MyConnection, MyDataSetAssoc.Tables(0).Rows(0)("itemvalue"), MyDataSetPrograms.Tables(0).Rows(0)("Program"))

然后将其绑定到控件:

CheckBoxList_Items.DataSource = MyDataSet
CheckBoxList_Items.DataMember = "Items"
CheckBoxList_Items.DataTextField = "ItemName"
CheckBoxList_Items.DataValueField = "ItemID"
This is the jquery code in the document ready function:

$(document).ready(function() {
  $('#<%= CheckBoxList_Items.ClientID %>').click(function() {
    if ($(this).is(":checked")) {
      alert("ID #" + this.value + " was just checked.");
    } else {
      alert("ID #" + this.value + " was just unchecked.");
    }
  });
});

单击列表中的任何复选框时都会执行此操作,现在我需要获取刚刚选中的复选框的值。 this.value未定义,并且仅执行语句else的一部分if,因此这样做不行。有没有办法可以获取刚刚触发此功能的复选框的值?或者我必须使用其他方法?列表中可以有 1 到 N 个项目,当一个复选框被“单击”时,我必须操作三个复选框列表。这个特定的复选框列表位于三个中最低的“级别”。

javascript
  • 2 个回答
  • 51 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve