【问题标题】:Draw an elliptical frame in xaml在xaml中画一个椭圆框
【发布时间】:2014-05-27 05:33:31
【问题描述】:

我需要在圆形图中显示一个数字。这对我来说是可行的,但是当有 2 位或 3 位数字时问题就开始了。预期会发生的是圆应该变成椭圆。如何在 xaml 中编写椭圆。椭圆本身可以显示为圆形吗?如何在椭圆中设置文字?

【问题讨论】:

  • 你的意思是椭圆形吗?那是“椭圆”。或者你的意思是一个圆圈暂时部分地遮住另一个圆圈? (实际上是“日食”)。
  • 安德鲁牧羊人:请检查

标签: .net silverlight xaml


【解决方案1】:

我过去曾使用此 TextBoxStyle 给我一些圆角,像我在这里所做的那样对其进行一些修改可能会给你一些可能有用的东西或给你一些想法。看看这样的东西是否适合你。

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:WpfApplication24" x:Class="WpfApplication24.MainWindow"
    Title="MainWindow" Height="350" Width="525">
<Window.Resources>
    <Style x:Key="TextBoxStyle" TargetType="{x:Type TextBox}">
        <Setter Property="FontSize" Value="20"/>
        <Setter Property="FontWeight" Value="Bold"/>
        <Setter Property="MinHeight" Value="50"/>
        <Setter Property="MaxHeight" Value="50"/>
        <Setter Property="HorizontalAlignment" Value="Left"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalAlignment" Value="Top" />
        <Setter Property="Padding" Value="4"/>
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TextBox}">
                    <Border SnapsToDevicePixels="true" x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="90,90,90,90">
                        <ScrollViewer SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" x:Name="PART_ContentHost" HorizontalAlignment="Center"  VerticalAlignment="Center"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</Window.Resources>
<Grid>
      <TextBox Style="{StaticResource TextBoxStyle }" BorderBrush="Black" BorderThickness="2" HorizontalContentAlignment="Stretch"  Text="12345" />
</Grid>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-04-14
    • 1970-01-01
    • 2016-09-15
    • 2017-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多