如何在XAML中设置前景色?

如何在XAML中设置前景色?,xaml,xamarin.forms,Xaml,Xamarin.forms,在Xamarin.Forms中,如何在XAML中设置文本框的前景色 我尝试了以下方法: <Style TargetType="{x:Type Entry}"> <Setter Property="BackgroundColor" Value="White" /> <Setter Property="Foreground" Value="Black" /> </Style> 我也试过: <Style TargetT

在Xamarin.Forms中,如何在XAML中设置文本框的前景色

我尝试了以下方法:

  <Style TargetType="{x:Type Entry}">
    <Setter Property="BackgroundColor" Value="White" />
    <Setter Property="Foreground" Value="Black" />
  </Style>
我也试过:

  <Style TargetType="{x:Type Entry}">
    <Setter Property="BackgroundColor" Value="White" />
    <Setter Property="ForegroundColor" Value="Black" />
  </Style>
当我尝试启动应用程序时,我收到一个意外的异常


有什么想法吗?

Xamarin论坛为我解答了这个问题:

  <Style TargetType="{x:Type Entry}">
    <Setter Property="BackgroundColor" Value="White" />
    <Setter Property="TextColor" Value="Black" />
  </Style>

xaml控件对象的前台和后台属性的类型为

<SolidColorBrush x:Key="whiteColorBrush" Color="white" />
<Style TargetType="{x:Type Entry}">
    <Setter Property="Foreground" Value="{StaticResource whiteColorBrush}" />
</Style>