WPF讲话泡泡 [英] WPF speech bubble

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

问题描述

我当前正在创建一个小软件,您可以在其中创建自己的漫画.我目前正在尝试添加气泡.我所做的是,将文本框放置在带有圆角的边框内.这是我的结果.

I'm currently creating a little soft where you can create your own Comic. I'm currently trying to add the speech bubbles. What i did is that i have put a Textbox inside a border with rounded corners.This is my result.

现在,我想添加一个指向字符说话的箭头(我所举的例子想得到).箭头的位置应由用户选择.它想绕边界旋转.我不知道是否可以做这样的事情.如果不是这样,用户可以在添加对话气泡之前(在八个基本方向之间)选择箭头的方向. 这是我用来创建气泡的代码:

Now i would like to add an arrow that points towards the character speaking(Example of what i would like to get). The position of the arrow should be chosen by the user. It would like rotate around the border. I don't know if it's possible to do something like that. If it's not i'd like that the user could choose the direction of the arrow before adding the speech bubble(between the eight basic directions). Here is the code i use to create my bubbles :

 Border bdrBubble = new Border();
            bdrBubble.BorderThickness = new Thickness(2);
            bdrBubble.BorderBrush = Brushes.Black;
            System.Windows.Controls.TextBox txtBubble = new System.Windows.Controls.TextBox();

            txtBubble.Background = Brushes.White;
            txtBubble.TextWrapping = TextWrapping.Wrap;
            txtBubble.AcceptsReturn = true;
            txtBubble.Background = Brushes.Transparent;

            txtBubble.BorderThickness = new Thickness(0);
            txtBubble.Text = tbxBubble.Text;
            bdrBubble.CornerRadius = new CornerRadius(100);
            txtBubble.ClipToBounds = true;
            bdrBubble.Background = Brushes.White;
            bdrBubble.Padding = new Thickness(10);
            txtBubble.TextAlignment = TextAlignment.Center;
            bdrBubble.Child = txtBubble;

希望有人可以指出我的最佳解决方案!

Hope someone could point me towards the best solution !

推荐答案

尚无此类现有功能,但是您可以根据需要更改以下箭头的方向,并访问以下链接并修改以下模板.坐标.

There is no such existing functionality, but you can visit the following links and modify the following template as per your needs to change the direction of the arrow based on the co-ordinates.

<Grid>
<Grid.RowDefinitions>
    <RowDefinition Height="*"/>
    <RowDefinition Height="40"/>
</Grid.RowDefinitions>
<Rectangle Fill="#FF686868" Stroke="#FF000000" RadiusX="10" RadiusY="10"/>
<Path Fill="#FF686868" Stretch="Fill" Stroke="#FF000000" HorizontalAlignment="Left" Margin="30,-5.597,0,-0.003" Width="25" Grid.Row="1" Data="M22.166642,154.45381 L29.999666,187.66699 40.791059,154.54395"/>                  
<Rectangle Fill="#FF686868" RadiusX="10" RadiusY="10" Margin="1"/>
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="25" Text="Hello World" TextWrapping="Wrap"/>                       
</Grid>

链接: 如何像气泡一样设置WPF工具提示的样式?

如何在WPF应用程序中实现气球消息

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

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