假设您有2个或更多共享相同结构的网格(行/列数和属性相等).
是否可以创建样式并设置RowDefinitions/ColumnDefinitions?
我试过了.但是当应用程序尝试解析xaml时,我得到此异常:
Xamarin.Forms.Xaml.XamlParseException:位置14:9.属性值为null或不是IEnumerable
我的源代码:
<StackLayout>
<StackLayout.Resources>
<ResourceDictionary>
<Style TargetType="Grid">
<Setter Property="RowDefinitions">
<Setter.Value>
<RowDefinition />
<RowDefinition />
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</StackLayout.Resources>
<Grid>
<Label Grid.Row="0" Text="(Grid #1) Row #1" />
<Label Grid.Row="1" Text="(Grid #1) Row #2" />
</Grid>
<Grid>
<Label Grid.Row="0" Text="(Grid #2) Row #1" />
<Label Grid.Row="1" Text="(Grid #2) Row #2" />
</Grid>
<Grid>
<Label Grid.Row="0" Text="(Grid #3) Row #1" />
<Label Grid.Row="1" Text="(Grid #3) Row #2" />
</Grid>
</StackLayout>
Run Code Online (Sandbox Code Playgroud)
异常中的位置14:9指的是第一个 …
我刚刚从2017.3.1f1更新了我的Unity到2018.2.1f1,当我打开我的项目时,它将manifest.json文件从UnityPackageManager文件夹移动到Packages文件夹.此外,它在Packages文件夹中创建了一堆文件和文件夹.
我的问题是:
从存储库中忽略Packages文件夹是否安全,特别是manifest.json?
谢谢.
我的 Xamarin Forms 应用程序中有以下按钮
<Button
Grid.Column="1"
Grid.Row="0">
<Button.ImageSource>
<FontImageSource Glyph="" FontFamily="{StaticResource IconFont}" Color="{StaticResource BaseColor}"/>
</Button.ImageSource>
</Button>
Run Code Online (Sandbox Code Playgroud)
在哪里IconFont:
<OnPlatform x:TypeArguments="x:String" x:Key="IconFont">
<On Platform="Android" Value="materialdesignicons-webfont.ttf#Material design" />
<On Platform="iOS" Value="Material Design Icons" />
</OnPlatform>
Run Code Online (Sandbox Code Playgroud)
一切正常。现在,因为我的所有图标都在里面materialdesignicons-webfont并且我永远不会使用不同的图标,所以我决定将整个样式移动到 App.xaml。我想设置这样的默认属性:
<Style TargetType="FontImageSource">
<Setter Property="FontFamily" Value="{StaticResource IconFont}" />
<Setter Property="Color" Value="{StaticResource BaseColor}" />
</Style>
Run Code Online (Sandbox Code Playgroud)
并仅通过传递字形来使用按钮。
<Button
Grid.Column="1"
Grid.Row="0">
<Button.ImageSource>
<FontImageSource Glyph=""/>
</Button.ImageSource>
</Button>
Run Code Online (Sandbox Code Playgroud)
对于一些原因图标不渲染不指定FontFamily和Color直接FontImageSource。我错过了什么吗?
有没有办法以更简单的方式调用我的按钮?铁
<Button
Grid.Column="1"
Grid.Row="0"
MDGlyph="" />
Run Code Online (Sandbox Code Playgroud) 最近,我不得不向Xamarin Forms移动应用程序添加一个功能。当用户按下后退按钮(在 Android 手机中)时,该功能会显示是/否提示。如果用户选择否,它将丢弃该按钮,否则,它将应用后退按钮,这将隐藏应用程序。
我知道为了检测Xamarin Forms 中的后退按钮,我必须覆盖Page.OnBackButtonPressed方法。为了绕过后退按钮,它应该返回true,如下所示:
protected override bool OnBackButtonPressed()
{
if (DisplayAlert("", "Are you sure?", "Yes", "No"))
return false;
return true;
}
Run Code Online (Sandbox Code Playgroud)
但问题在于,Page.DisplayAlert是一种异步方法,必须在主 (UI) 线程上调用。所以经过大量的搜索,我想出了这个我想分享的想法。
我对如何改进的任何想法/建议持开放态度。