0

I'm new to XAML and likely not even thinking about this problem in the right way, but...

Basically I want a little XAML fragment that I can inject into various UserControls under some circumstances. The XAML just shows a small tag at the side of the control using a Border and a TextBlock.

It would be easy enough to cut and paste this to each control, but that feels clumsy and will be a pain any time I want to update it. Sure, I could do this at runtime in the control base class, but I would rather use the designer. I could make the tag a UserControl in its own right, but that sounds needlessly heavyweight too.

So is there some way of making little XAML fragments in the designer that I'm missing? I'm thinking there it would just have (in this case) the Border at the root of the XAML document.

This is for a Windows 8 store app using VS2013.

terriblememory
  • 1,712
  • 3
  • 18
  • 25
  • You could apply my answer [here](http://stackoverflow.com/questions/13292179/best-way-to-use-a-vector-image-in-wpf/13293017#13293017) and just put it in your resource dictionary or generic.xaml or something so it can be reached as a StaticResource, then your multi-line becomes one line and you can re-use it all over the place easily and change it just one place when edits are necessary. – Chris W. Sep 28 '14 at 15:43
  • That's *kind* of what I want, but does that allow me to edit the XAML using the VS designer? – terriblememory Sep 28 '14 at 18:07
  • Of course, easiest route, wherever you have it on your view, right-click the ContentControl and choose "Edit Template->Edit Current" and it will open it up. – Chris W. Sep 28 '14 at 23:53

1 Answers1

0

Have you tried XAML Code Snippets? Tim Heuer has a nice post with examples here: http://timheuer.com/blog/archive/2013/07/08/xaml-code-snippets-for-visual-studio.aspx

John Holliday
  • 1,268
  • 1
  • 11
  • 19