5

I'm trying to create a speech bubble control for my UWP app in c#/XAML that scales based on it's content. It's based on a the following questing:

How to create a speech bubble in UWP?

The problem with the link above is, it does not work with transparency in brushes(=>borders are visible).

Result of the link above

I know I could use a Polygon and just set the Stretch property but with that solution I would also stretch the triangle not just the content rectangle.

So I thought about extending Windows.UI.Xaml.Shapes.Shape (like Rectangle, Circle, Polygon, ... do) but I'm unable to find any documentation about how to do this.

Summary:

  • A speech bubble control that works with transparent brushes and non transparent border brushes.

  • It should scales based on it's content.

  • Only the content rectangle should scale/stretch not the triangle.

COM8
  • 271
  • 1
  • 10
  • Interesting question, my opinion is that you will have to draw it in the code, but let's see what other people say. – Ivan Ičin Dec 23 '18 at 11:29
  • So you want to set "background" of the bubble and a different brush for the border. Am I understanding it correctly? – Michal Kania Dec 23 '18 at 12:35
  • Yes I want for example a `Black` border and `Acrylic` as fill color. – COM8 Dec 23 '18 at 12:41
  • @ivan-ičin Yes, was planing this by extending `Windows.UI.Xaml.Shapes.Shape` but I was unable to find any example/documentation about how to do it. – COM8 Dec 23 '18 at 12:43
  • multiple way to do this, but whats your opinion about to use path data with viewbox ? where path data will help you to generate shape and viewbox will resize the content. – Shubham Sahu Dec 23 '18 at 13:18
  • If you want to use transparency, then there's one way - you need to draw it as a whole, or you might encounter "glitches", "see through" and other unnecessary borders. – Michal Kania Dec 23 '18 at 13:29
  • If there is a way to not scale the triangle only the rectangle - sure! – COM8 Dec 23 '18 at 13:29
  • Isn't this possible by extending `Windows.UI.Xaml.Shapes.Shape` and then draw it based on the current size of the new shape? – COM8 Dec 23 '18 at 13:58
  • And there use a `Polygon` for the shape – COM8 Dec 23 '18 at 13:58

0 Answers0