有没有一种方法可以向选择器添加仅在聚焦后才可见的边框?我不确定自己是否在解释自己,但就像我只希望用户尝试从选择器中选择项目时边框可见。我正在处理xamarin表格。这是我的代码。预先谢谢你
<StackLayout Orientation="Horizontal">
<Label VerticalOptions="Start" HorizontalOptions="StartAndExpand"
Text="Project"
WidthRequest="100"/>
<Picker Title="Please Select" HorizontalOptions="StartAndExpand" WidthRequest="255">
<Picker.Items>
<x:String>Andalucia</x:String>
<x:String>Atlantico</x:String>
<x:String>Berkley Square</x:String>
<x:String>Cooper City</x:String>
<x:String>Valencia Bay</x:String>
</Picker.Items>
<Picker.Triggers>
<Trigger TargetType="Picker"
Property="IsFocused" Value="True">
<Setter Property="BackgroundColor" Value="Azure">
</Setter>
</Trigger>
</Picker.Triggers>
</Picker>
</StackLayout>
答案 0 :(得分:0)
将Picker
包含在Frame
(或最适合您需要的控件)中。
<StackLayout Orientation="Horizontal" VerticalOptions="Center">
<Label VerticalOptions="Start"
HorizontalOptions="StartAndExpand"
Text="Project"
WidthRequest="100"/>
<Frame OutlineColor="Transparent"
HorizontalOptions="StartAndExpand"
WidthRequest="255"
Padding="2">
<Frame.Triggers>
<Trigger TargetType="Frame" Property="IsFocused" Value="True">
<Setter Property="OutlineColor" Value="Red" />
</Trigger>
</Frame.Triggers>
<Picker Title="Please Select">
<Picker.Items>
<x:String>Andalucia</x:String>
<x:String>Atlantico</x:String>
<x:String>Berkley Square</x:String>
<x:String>Cooper City</x:String>
<x:String>Valencia Bay</x:String>
</Picker.Items>
<Picker.Triggers>
<Trigger TargetType="Picker" Property="IsFocused" Value="True">
<Setter Property="BackgroundColor" Value="Blue" />
</Trigger>
</Picker.Triggers>
</Picker>
</Frame>
</StackLayout>