多边形中的VisualBrush [英] VisualBrush in Polygon

查看:58
本文介绍了多边形中的VisualBrush的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个控制权:

I have this control:


多边形不是正方形,但是我试图在多边形的边缘绘制边框,这意味着右上角像素将位于多边形(100,10)的右上角,与右下角相同(100,90),它不会剪切图像.

The Polygon is not a square but I am trying to make the border be drawn on the edge of the Polygon, meaning that the top right pixel will be at the top right point of the polygon (100,10), same with the bottom right (100,90) and it won't cut the image.

在我的情况下,没有边框,而是带有内容的完整网格,边框仅用于示例.

In my case there is no border but a full grid with content, the Border is just for the example.

推荐答案

嗨Itamar Epstein,
>>多边形"不是正方形,但我正在尝试在多边形"的边缘绘制边框
如果您需要这样的东西:

Hi Itamar Epstein,
>>The Polygon is not a square but I am trying to make the border be drawn on the edge of the Polygon
If you need something like this:

您可以使用Stroke:

You could use Stroke :

    <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top">
        <Border x:Name="MainBorder" BorderBrush="Blue" Background="Gray" Height="100" Width="100">
            <TextBlock Foreground="Black" FontSize="35" HorizontalAlignment="Center"> 
                    <Run Text="Test"/>
                    <LineBreak/>
                    <Run Text="Test"/>
            </TextBlock>
        </Border>
        <Polygon Stroke="Blue" StrokeThickness="3" Points="0,0 100,10 100,90 0,100" Margin="0,20,0,0">
            <Polygon.Fill>
                <VisualBrush Visual="{Binding ElementName=MainBorder}" Stretch="Fill"/>
            </Polygon.Fill>
        </Polygon>
    </StackPanel>

最好的问候,

Annievia Chen

Annievia Chen


这篇关于多边形中的VisualBrush的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆