【问题标题】:Load custom polygon as button image in WPF在 WPF 中将自定义多边形加载为按钮图像
【发布时间】:2015-04-30 14:03:26
【问题描述】:

我使用多边形制作了一个小十字图标,如下所示:

  <Viewbox Margin="28,-22,-28,22">
        <Polygon
Points="300, 200 325,200 325,250 375,250 375,275 325,275 325,325 300,325 300,275 250,275 250,250 300,250 300,200" Height="513" Width="595">
            <Polygon.Fill>
                <SolidColorBrush Color="#666666" Opacity="100"/>
            </Polygon.Fill>
            <Polygon.RenderTransform>
                <RotateTransform CenterX="313" CenterY="237" Angle="45" />
            </Polygon.RenderTransform>
        </Polygon>
    </Viewbox>

现在我希望将此多边形加载到我的按钮中。我该怎么做?

【问题讨论】:

    标签: c# wpf button polygons


    【解决方案1】:

    把它放在Button.Content

    <Button ...>
        <Viewbox ...>
        </Viewbox>
    </Button>
    

    不要忘记删除ViewBox.Margin(使Button足够大)或将其设为负数。


    【讨论】:

    • 谢谢。现在的问题是如何让 ViewBox 将多边形包裹起来而周围没有任何额外的空间?
    • 有很多选择:1) 改变点,使它们从(0,0) 开始 2) 缩放 3) 负边距 4) 渲染变换等。见编辑。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-29
    • 2012-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多