3

Windows ストア アプリ (C++) の角を丸くしたテキスト ボックスが必要でした。コントロール テンプレートを XAML テキスト ボックスに適用して角を丸くしました。XAML は初めてです。このコードに欠けているものを見つけて編集可能にするのを手伝ってください。

エッジを丸くした後のコードは次のとおりです。

<TextBox HorizontalAlignment="Left" Margin="51,202,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="23" Width="246" Background="White" BorderBrush="#FF00AAA6" IsReadOnly="False">
        <TextBox.Resources>
            <ControlTemplate x:Key="TextBoxControlTemplate1" TargetType="TextBox">
                <Grid>
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="CommonStates">
                            <VisualState x:Name="PointerOver"/>
                            <VisualState x:Name="Focused"/>
                            <VisualState x:Name="Disabled"/>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="ButtonStates">
                            <VisualState x:Name="ButtonCollapsed"/>
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                    <Border BorderThickness="1" Padding="2" CornerRadius="3" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"/>
                </Grid>
            </ControlTemplate>
        </TextBox.Resources>
        <TextBox.Template>
            <StaticResource ResourceKey="TextBoxControlTemplate1"/>
        </TextBox.Template>
    </TextBox>           
4

1 に答える 1

0

サンプル コードでは、ControlTemplate に ContentElement が含まれていないため、編集可能な入力要素が不足しています。

以下のリンクを使用して TextBox の実際のスタイルを確認し、丸みを帯びたビジュアルの関連する境界線の「CornerRadius」プロパティのみを変更します

テキストボックス スタイル

于 2013-02-04T08:18:43.703 に答える