WPF 自定义TextBox 前加图标和圆角 转载

时间:2025-04-17 17:01:59

<Style  x:Key="TXTSTYLE" TargetType="{x:Type TextBox}">

            <Setter Property="Template">

                <>

                    <ControlTemplate TargetType="{x:Type TextBox}">

                        <Grid>

                            <>

                                <ColumnDefinition Width="40" />

                                <ColumnDefinition />

                            </>

                            <Label Background="{TemplateBinding Background}"/>

                            <Border ="1" x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{DynamicResource {x:Static }}" SnapsToDevicePixels="true">

                                <ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>

                            </Border>

                        </Grid>

                    </ControlTemplate>

                </>

            </Setter>

        </Style>