0

Is it possible to customize default user control markup in xaml ?

Let's say i have a user control named MyUserControl.

What I would like to know - is it possible, when I type

  <controls:MyUserControl -and then type- > 

instead of just ending up with

  <controls:MyUserControl ></controls:MyUserControl>

to have

  <controls:MyUserControl DependencyProperty="1" DependencyProperty="Person" ... ></controls:MyUserControl>'

Basically I want to create a custom template that would be used when auto-completing user control in xaml editor.

Purpose is to show the user available properties right away ( user that wants to use some control that he did not use before can see how to change important properties without browsing all possible properties on user control )

frno
  • 1,064
  • 11
  • 24
  • That's what Intellisense is for. – Sheridan Feb 18 '14 at 13:49
  • I think I explained clearly that the intention here is to not browse through all possible properties in intellisence but rather provide direct properties that are important – frno Feb 19 '14 at 10:03

1 Answers1

0

As far as I am aware, there is no simple way to do that, but I'd say that it was unadvisable to try to do that anyway. You said that you want to show the user available properties right away, but that is what Microsoft's Intellisense in Visual Studio is for. Once you have declared your DependencyPropertys, they'll automatically appear in a popup when a user is using your class.

As the .NET controls do not do what you suggest, then yours shouldn't really do that either. You're more likely to confuse developers with this unusual behaviour and they might even leave these added and quite possibly unwanted properties because they don't know any better. Your best bet to help users of your code is to implement it in as standard a way as possible, so that everything will work as expected.

You know, the most annoying bugs are caused from problems with code that was meant to help us.

Sheridan
  • 68,826
  • 24
  • 143
  • 183
  • I remember it is possible to do this in ASP.NET, you can customize the markup. I was just wandering if it is possible for WPF, but I could not find anything ... – frno Feb 19 '14 at 10:05
  • I don't think that there would be bugs here, since you are using already created DP's with let's say default values, those would be used anyway ... I see this more as an option, like shortcuts for different property creation with 'prop', 'propa', 'propdp' etc. - you have different options for automatic code creation ... might be useful, or as you suggested, maybe sometimes confusing, but could save time - no browsing through often many properties ... – frno Feb 19 '14 at 12:15