How to design words balloon in WinRT XAML?

你离开我真会死。 提交于 2019-12-13 05:19:08

问题


I am trying to create words balloon looks like below image. How to design words balloon in WinRT XAML? Thanks.

balloon image

<Grid Width="400">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="22*"/>
        <ColumnDefinition Width="5*"/>
    </Grid.ColumnDefinitions>
    <Image Source="{Binding Image}" Margin="10,2,10,0" Grid.Column="2" VerticalAlignment="Top" />
    <Border BorderBrush="Black" BorderThickness="3" HorizontalAlignment="Right" VerticalAlignment="Top" CornerRadius="4">
        <TextBlock HorizontalAlignment="Right" TextWrapping="Wrap" Text="bla bla bla..." Margin="5,10" IsTextSelectionEnabled="True" MaxWidth="280"/>
    </Border>


回答1:


Here you go

<Path Width="100" Fill="#4F81BD" Stretch="uniform" Stroke="#385D8A" StrokeThickness="3" Data="M 100,119 C 102,109 107,101 120,100 L 220,100 C 231,101 241,110 240,120 L 241,159 C 241,170 230,180 220,180 L 120,180 C 111,180 100,171 100,160 L 100.5,139.5 L 70,120 Z"/>

You may adjust according to your use

You can use it as background brush, drawing image, geometry and even opacity mask if you look for special effects.

sample for you

<Border HorizontalAlignment="Right" VerticalAlignment="Top" >
     <TextBlock MaxWidth="280"
        HorizontalAlignment="Right"
        Margin="30,10,10,10"
        Text="bla bla bla..."
        TextWrapping="Wrap"/>
     <Border.Background>
        <DrawingBrush>
           <DrawingBrush.Drawing>
              <GeometryDrawing Brush="#4F81BD">
                 <GeometryDrawing.Pen>
                    <Pen Brush="#385D8A" Thickness="6"/>
                 </GeometryDrawing.Pen>
                 <GeometryDrawing.Geometry>
                    <PathGeometry Figures="M 100,119 C 102,109 107,101 120,100 L 220,100 C 231,101 241,110 240,120 L 241,159 C 241,170 230,180 220,180 L 120,180 C 111,180 100,171 100,160 L 100.5,139.5 L 70,120 Z"/>
                 </GeometryDrawing.Geometry>
              </GeometryDrawing>
           </DrawingBrush.Drawing>
        </DrawingBrush>
     </Border.Background>
  </Border>

sample 2

<Grid HorizontalAlignment="Center" VerticalAlignment="center">
   <Path
      Width="100"
      Data="M 100,119 C 102,109 107,101 120,100 L 220,100 C 231,101 241,110 240,120 L 241,159 C 241,170 230,180 220,180 L 120,180 C 111,180 100,171 100,160 L 100.5,139.5 L 70,120 Z"
      Fill="#4F81BD"
      Stretch="uniform"
      Stroke="#385D8A"
      StrokeThickness="3"/>
   <TextBlock
      MaxWidth="280"
      Margin="30,15,10,10"
      Text="bla bla bla..."
      TextWrapping="Wrap"/>
</Grid>


来源:https://stackoverflow.com/questions/23668788/how-to-design-words-balloon-in-winrt-xaml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!