可扩展应用程序标记语言(XAML)是一种基于XML的声明式语言,用于在各种框架中初始化结构化值和对象。当问题是关于具有特定框架的XAML的使用时,还应该提供框架的标签,例如, [wpf](Windows Presentation Foundation),[silverlight],[windows-phone],[windows-store-apps](Windows 8商店应用),[win-universal-app],[xamarin.forms]或[工作流程 - 基础]
ERROR消息设计时间:“无法找到资源'样式/纽扣styles.xaml'”
在以下情况下出现了一个神秘的信息: 无法找到资源'样式/纽扣styles.xaml' 此消息仅出现在设计模式下,无法避免。如果我重建SO ...
XLS0504属性'fontfamily'不支持类型'onplatform`1(t)'xamarin forms formsforms
我正在尝试在我的fontawsome项目中添加Xamarin forms图标。我关注的是本教程这样做。但是,当我使用以下代码时, <Button.FontFamily> <OnPlatform></OnPlatform> </Button.FontFamily> 它显示错误。那就是XLS0504 Property 'FontFamily' does not support values of type 'OnPlatform1(t)'.如何解决此错误? Xamarin Version - 5.0.0.2012 是因为您需要将fontfamily指定为字符串。 trone类似于以下内容: <Button.FontFamily> <OnPlatform x:TypeArguments="x:String"> <On Platform="iOS" Value="iOSFont" /> <On Platform="Android" Value="AndroidFont" /> <On Platform="UWP" Value="UWPFont" /> </OnPlatform> </Button.FontFamily>
使用C#添加wpf代码中的fontawesome图标到数据网格行
i有一个带有行的数据杂志,从编程中开始添加,而我的datagrid in xaml有5列,每个列样式如下所示: <DataGrid.Columns> <DataGridTextColumn Width="Auto" Header="Status" FontFamily="Arial" Foreground="Gray" FontWeight="Normal" MinWidth="250" Binding="{Binding Path=Date}" > <DataGridTextColumn.HeaderTemplate> <DataTemplate> <StackPanel> <fa:ImageAwesome Icon="Sort" Height="10" Name="Search" Margin="10,15,25,0" HorizontalAlignment="Center" /> <!--<TextBlock FontFamily="FontAwesome" FontSize="16" Text="" />--> <TextBlock Text="Date" Margin="0,-30,0,0" /> </StackPanel> </DataTemplate> </DataGridTextColumn.HeaderTemplate> <DataGridTextColumn.ElementStyle> <Style> <Setter Property="FrameworkElement.HorizontalAlignment" Value="Center"/> <Setter Property="FrameworkElement.Margin" Value="0,8,0,0"></Setter> </Style> </DataGridTextColumn.ElementStyle> <DataGridTextColumn.HeaderStyle> <Style TargetType="{x:Type DataGridColumnHeader}"> <Setter Property="HorizontalContentAlignment" Value="Center" /> <Setter Property="Background" Value="#dec15a" /> <Setter Property="Height" Value="50" /> <Setter Property="FontWeight" Value="Bold" /> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="#d5b024" /> </Trigger> </Style.Triggers> </Style> </DataGridTextColumn.HeaderStyle> </DataGridTextColumn> </DataGrid.Columns> 如何在文本旁边添加字体上的成功图标,如下所示,当行从后面添加代码时添加 Date | File| Status 03/14/2025|.pdf | Success (here the FontAwesome success icon should be shown) Code-Behind代码为: dgrd_ListFiles.Items.Add(new Item() { Date = System.DateTime.Now.ToString("MM/dd /yyyy"), File=".pdf", Status = "Success" }); 我认为以下情况应在您的情况下起作用。修改如下:标签: DataGridTextColumn.ElementStyle
我在悬停在按钮上以及活动按钮的颜色上时效果有问题。如何实施? 主要问题是,当您悬停在按钮上时,C ...
使用C#添加wpf代码中的wpf代码中的数据网格行添加了“真棒图标”
where是一个数据杂志,具有编程性添加行的行,而我的datagrid in XAML,带有5列,每个列样式均为下面 <DataGrid.Columns> <DataGridTextColumn Width="Auto" Header="Status" FontFamily="Arial" Foreground="Gray" FontWeight="Normal" MinWidth="250" Binding="{Binding Path=Date}" > <DataGridTextColumn.HeaderTemplate> <DataTemplate> <StackPanel> <fa:ImageAwesome Icon="Sort" Height="10" Name="Search" Margin="10,15,25,0" HorizontalAlignment="Center" /> <!--<TextBlock FontFamily="FontAwesome" FontSize="16" Text="" />--> <TextBlock Text="Date" Margin="0,-30,0,0" /> </StackPanel> </DataTemplate> </DataGridTextColumn.HeaderTemplate> <DataGridTextColumn.ElementStyle> <Style> <Setter Property="FrameworkElement.HorizontalAlignment" Value="Center"/> <Setter Property="FrameworkElement.Margin" Value="0,8,0,0"></Setter> </Style> </DataGridTextColumn.ElementStyle> <DataGridTextColumn.HeaderStyle> <Style TargetType="{x:Type DataGridColumnHeader}"> <Setter Property="HorizontalContentAlignment" Value="Center" /> <Setter Property="Background" Value="#dec15a" /> <Setter Property="Height" Value="50" /> <Setter Property="FontWeight" Value="Bold" /> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Background" Value="#d5b024" /> </Trigger> </Style.Triggers> </Style> </DataGridTextColumn.HeaderStyle> </DataGridTextColumn> </DataGrid.Columns> 如何在文本旁边添加字体上的成功图标,如下所示,当行从后面添加代码时添加 Date | File| Status 03/14/2025|.pdf | Success (Here should come the font awesone succes icon) 代码背后的编码是 dgrd_ListFiles.Items.Add(new Item() { Date = System.DateTime.Now.ToString("MM/dd /yyyy"), File=".pdf", Status = "Success" }); 我认为以下情况应在您的情况下起作用。修改如下:标签: DataGridTextColumn.ElementStyle
.NETMAUI CollectionView。更改对一个项目的视图属性会影响错误的项目。回收问题?
I有一个分组的CollectionView,该视图在每个项目的视图中显示一个自定义控件。根据我的阅读,自定义控件没有设置自己的绑定上下文,而是使用可绑定的属性来获取数据。
如何将双重转换为XAML(x:bind)中的厚度? 我试图将滑块控件的价值传递给另一个控制的边界厚度:
<Border BorderThickness="{x:Bind ThicknessSlider.Value, Mode=OneWay}"> </Border> 但是发生此错误: cannot直接将类型的“ system.double”绑定到 'Microsoft.ui.xaml.thickness'。使用铸件,转换器或功能 绑定以更改类型 如何完成此转换? 您可以创建这样的转换器: doubletothicknessconverter.cs using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Data; using System; namespace Converters; public class DoubleToThicknessConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { if (value is double doubleValue) { List<int>? coefficients = (parameter as string)? .Split(',') .Select(x => int.Parse(x)) .ToList<int>(); if (coefficients?.Count is not 4) { coefficients = new() { 1, 1, 1, 1 }; } return new Thickness( left: doubleValue * coefficients[0], top: doubleValue * coefficients[1], right: doubleValue * coefficients[2], bottom: doubleValue * coefficients[3]); } throw new ArgumentException(); } public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); } } 使用这样的使用: mainpage.xaml <Page x:Class="Converters.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="using:Converters" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" mc:Ignorable="d"> <Page.Resources> <local:DoubleToThicknessConverter x:Key="DoubleToThicknessConverter" /> </Page.Resources> <Border BorderBrush="SkyBlue" BorderThickness="{x:Bind ThicknessSlider.Value, Mode=OneWay, Converter={StaticResource DoubleToThicknessConverter}, ConverterParameter='0,3,1,3'}"> <Slider x:Name="ThicknessSlider" /> </Border> </Page> update 添加任意系数作为转换器参数。现在,您可以将系数设置为左,右,底部和底部的厚度。 例如,如果您只想使用底部厚度或设置'1,2,1,2'将顶部和底部的厚度加倍,则可以设置“ 0,0,0,0”。
我在我的页面上具有3列的控制。我需要做的是用各自的数据填充每一列。 我有一个定义“完整”的类,该课程由3个字符串(站点,距离和Gasprice)组成
<ToggleButton x:Name="toggleSwitch" Width="30" Height="18" Style="{StaticResource CustomToggleSwitch}"/> <Style TargetType="ToggleButton" x:Key="CustomToggleSwitch"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ToggleButton"> <StackPanel> <Border x:Name="BorderElement" CornerRadius="8" Width="28" Height="18"> <Border.Background> <SolidColorBrush Color="#252525"/> </Border.Background> <Border.BorderBrush> <SolidColorBrush Color="#333333"/> </Border.BorderBrush> <Border.BorderThickness> <Thickness>2</Thickness> </Border.BorderThickness> <Ellipse x:Name="SwitchEllipse" Fill="#848386" Width="10" Height="10" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="2"> <Ellipse.RenderTransform> <TranslateTransform x:Name="EllipseTranslateTransform" /> </Ellipse.RenderTransform> </Ellipse> </Border> </StackPanel> <ControlTemplate.Triggers> <Trigger Property="IsChecked" Value="True"> <Setter TargetName="SwitchEllipse" Property="Fill" Value="#F5F1FF"/> <Setter TargetName="BorderElement" Property="Background" Value="#725DFF"/> <Trigger.EnterActions> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName="EllipseTranslateTransform" Storyboard.TargetProperty="X" To="25" Duration="0:0:0.2"/> <!-- Движение вправо --> </Storyboard> </BeginStoryboard> </Trigger.EnterActions> </Trigger> <Trigger Property="IsChecked" Value="False"> <Setter TargetName="SwitchEllipse" Property="Fill" Value="#848386"/> <Setter TargetName="BorderElement" Property="Background" Value="#252525"/> <Trigger.EnterActions> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName="EllipseTranslateTransform" Storyboard.TargetProperty="X" To="0" Duration="0:0:0.2"/> <!-- Возвращение влево --> </Storyboard> </BeginStoryboard> </Trigger.EnterActions> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style>
I tried using an approach with grids and scrollviews like these
我想在我的毛伊岛应用程序上使用开关控件,但是我找不到如何正确地将其居中。 为了可视化问题,我将背景色设置为像这样的浅色: 我想在我的毛伊岛应用程序上使用开关控件,但是我找不到如何正确地将其居中。 为了可视化问题,我将BackgroundColor设置为LightCoral<Switch OnColor="Aquamarine" ThumbColor="Navy" BackgroundColor="LightCoral" HorizontalOptions="Center"> </Switch> :: HorizontalOptions="Center" 您可以看到开关控件本身贴在左侧。使用<Grid BackgroundColor="LightCoral" HeightRequest="40" HorizontalOptions="Center" WidthRequest="154"> <Switch HorizontalOptions="Start" OnColor="Aquamarine" ThumbColor="Navy" TranslationX="57" /> </Grid> 仅移动整个“粉红色块”,但在其中控制控制在最左边。有没有办法绕过此默认样式?谢谢 当我测量控制时,我发现它是154x40。当我测量滑块部分时,大约是40x20,正如您确定的那样,左侧是合理的。因此,要将其重新放置在中心,我需要用57个像素将其向右移动,例如 ToggleSwitch 这是您可以在github上找到的一个问题,[1111](https://github.com/microsoft/microsoft/microsoft-ui-xaml/issues/3652,)内部将控制设置为154。 MinWidth希望它有帮助!
。 我有以下问题使用iPhone 16时出现的问题。 毛伊岛应用程序不使用shell,如果这可能以任何方式有用... 这里有一个完整的毛伊示例项目 解释 Pro ...
毛伊岛应用程序是使用shell如果以任何方式有用的...