如何以编程方式将带有文本块的装饰器添加到画布?
我正在跟踪包含此 xaml 的代码示例,但如何以编程方式构建此代码并将其添加到画布中?
<custom:BalloonDecorator Background="{StaticResource MessageOutBackground}" PointerLength="10"
CornerRadius="5" Margin="10,0,0,0"
HorizontalAlignment="left">
<Border Background="{StaticResource Hilight}" CornerRadius="5">
<Border Background="{StaticResource HilightBottom}"
CornerRadius="5">
<TextBlock Text="Hello" HorizontalAlignment="Left" VerticalAlignment="Top"/>
</Border>
</Border>
</custom:BalloonDecorator>
I'm following a code sample that has this xaml, but how can I construct this programmatically and add it to a canvas?
<custom:BalloonDecorator Background="{StaticResource MessageOutBackground}" PointerLength="10"
CornerRadius="5" Margin="10,0,0,0"
HorizontalAlignment="left">
<Border Background="{StaticResource Hilight}" CornerRadius="5">
<Border Background="{StaticResource HilightBottom}"
CornerRadius="5">
<TextBlock Text="Hello" HorizontalAlignment="Left" VerticalAlignment="Top"/>
</Border>
</Border>
</custom:BalloonDecorator>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使其成为窗口(或其他东西)的资源:
然后在如下代码中获取它:
Make it a resource of the window (or something else):
Then get it in code like this: