【发布时间】:2018-04-15 12:26:04
【问题描述】:
我正在尝试自定义 UWP 中 Picker 的外观(我想移除下拉箭头),并且我在 UWP App.Xaml 中定义了一个控件模板,类似于:
<Application
x:Class="StoreFulfillment.UWP.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:StoreFulfillment.UWP"
RequestedTheme="Light">
<Application.Resources>
<ResourceDictionary>
<Style x:Name="PickerStyle" TargetType="ComboBox">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ComboBox">
<Grid>
...
...
...
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>
在我的选择器自定义渲染器中,我想将 Picker UWP 控件(它是一个 ComboBox)的 Style 属性设置为 Xaml 中定义的 PickerStyle,如下所示:
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
base.OnElementChanged(e);
...
...
...
Control.Style = (Windows.UI.Xaml.Style)Application.Current.Resources["PickerStyle"];
}
但是Application.Current.Resources 不包含我在 Xaml 中定义的样式。如何从自定义渲染器中引用或访问它?
【问题讨论】:
标签: c# xaml xamarin.forms uwp-xaml xamarin.uwp