0
長方形の代わりにエリプシスや三角形の枠線のようなカスタムシェイプのテキストボックスが必要なのですか?TextBoxのデフォルトの枠線の代わりにカスタムシェイプを使用できますか?
長方形の代わりにエリプシスや三角形の枠線のようなカスタムシェイプのテキストボックスが必要なのですか?TextBoxのデフォルトの枠線の代わりにカスタムシェイプを使用できますか?
はい、コントロールのStyle
をニーズに合わせて変更できます。
<Style x:Key="TextBox.Ellipse" TargetType="{x:Type TextBox}">
<!--Here you can set the default properties of this style.-->
<Setter Property="FontWeight" Value="Bold"/>
<!--You can change the shape of the control by setting the template-->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Grid>
<Ellipse x:Name="Border" Stroke="#FF393785" StrokeThickness="2">
<Ellipse.Fill>
<RadialGradientBrush GradientOrigin="0.25,0.25"
RadiusY="0.75" RadiusX="0.75">
<GradientStop Color="White" Offset="0.2"/>
<GradientStop Color="#FF2EC452" Offset="0.5"/>
<GradientStop Color="#FF606060" Offset="1"/>
</RadialGradientBrush>
</Ellipse.Fill>
</Ellipse>
<!-- The implementation places the Content into the ScrollViewer.
It must be named PART_ContentHost
for the control to function -->
<ScrollViewer x:Name="PART_ContentHost" Background="Transparent"
HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Fill" Value="#000" TargetName="Border"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
その後、あなたはこのようなTextBox
のスタイルを設定することができます
など、App.Xaml
などのリソースディクショナリ内のこのStyle
を置く:
<TextBox Style="{StaticResource TextBox.Ellipse}" />