本文介绍了有没有什么办法的造型从我Xamarin.Forms XAML分开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用与XAML页面的PCL Xamarin.Forms。我想通了样式我控制的唯一方式是使用内联语法



<按钮文本=探究TEXTCOLOR =蓝/>



我宁愿使用这样的结构之一:



< Page.Resources>
<风格的TargetType =按钮>
< setter属性=了borderThicknessVALUE =5/>
< setter属性=前景VALUE =蓝/>
< /样式和GT;
< /Page.Resources>



()



然而,是不是(还)支持的风格元素。
有没有人成功地从内容中分离布局



FYI:我也张贴在Xamarin论坛这个问题,所以任何人谁由谷歌来到这里可能要还检查了这个网页:的


解决方案

从Xamarin.Forms 1.3你得到更多的时尚选择。






  • 在XAML和代码支持样式

  • 允许样式通过Style.BaseResourceKey基于DynamicResources

  • 通过Device.Styles(支持iOS的动态类型)


添加特定平台的样式

I'm using Xamarin.Forms in a PCL with the XAML pages. The only way I figured out to style my controls is to use an inline syntax.

<Button Text="Inquiry" TextColor="Blue" />

I would prefer to use a structure like this one:

<Page.Resources>
    <Style TargetType="Button">
        <Setter Property="BorderThickness" Value="5" />
        <Setter Property="Foreground" Value="Blue" />
    </Style>
</Page.Resources>

(http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh465381.aspx)

However, the Style element is not (yet) supported.Has anyone succeeded in separating the layout from the contents?

FYI: I've also posted this question in Xamarin forums, so anyone who got here by google might want to also check out this page: http://forums.xamarin.com/discussion/19287/styling-of-xamarin-xaml#latest

解决方案

From Xamarin.Forms 1.3 you get more styling options.

Xamarin.Forms 1.3 Technology Preview

  • Support styles in XAML and in code
  • Allow styles to be based on DynamicResources via Style.BaseResourceKey
  • Add platform specific styles via Device.Styles (supports iOS dynamic type)

这篇关于有没有什么办法的造型从我Xamarin.Forms XAML分开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 16:52