Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Custom markup extensions in the VS wpf designer

Custom markup extensions in the VS wpf designer

Scheduled Pinned Locked Moved WPF
csharpvisual-studiohtmlwpfquestion
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jamie550
    wrote on last edited by
    #1

    I am using VS2008 SP1. I have a solution with two projects. Project A is a class library, and has a markup extension.

    public class BadExtension : MarkupExtension
    {
    	public string A { get; set; }
    	public string B { get; set; }
    
    	public BadExtension() { }
    	public BadExtension(string a) { this.A = a; }
    	public BadExtension(string a, string b) { this.A = a; this.B = b; }
    
    	public override object ProvideValue(IServiceProvider serviceProvider) { return A + B; }
    }
    

    Project B is a wpf project. Part of the code of a window is

    Now, the WPF designer refuses to load, saying that no constructor for BadExtension has 1 parameter. However, when I run the app, it loads perfectly and both button texts display perfectly. This is the kicker: In the BadExtension.cs file, if I switch the (string) and (string, string) constructors, the designer now complains about no constructor having 2 parameters. p.s. Or should this be in the Visual Studio forum?

    M 1 Reply Last reply
    0
    • J jamie550

      I am using VS2008 SP1. I have a solution with two projects. Project A is a class library, and has a markup extension.

      public class BadExtension : MarkupExtension
      {
      	public string A { get; set; }
      	public string B { get; set; }
      
      	public BadExtension() { }
      	public BadExtension(string a) { this.A = a; }
      	public BadExtension(string a, string b) { this.A = a; this.B = b; }
      
      	public override object ProvideValue(IServiceProvider serviceProvider) { return A + B; }
      }
      

      Project B is a wpf project. Part of the code of a window is

      Now, the WPF designer refuses to load, saying that no constructor for BadExtension has 1 parameter. However, when I run the app, it loads perfectly and both button texts display perfectly. This is the kicker: In the BadExtension.cs file, if I switch the (string) and (string, string) constructors, the designer now complains about no constructor having 2 parameters. p.s. Or should this be in the Visual Studio forum?

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      Looks like a bug in the VS designer.

      jamie550 wrote:

      when I run the app, it loads perfectly and both button texts display perfectly.

      It works fine in Expression Blend as well. Mark

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      J 1 Reply Last reply
      0
      • M Mark Salsbery

        Looks like a bug in the VS designer.

        jamie550 wrote:

        when I run the app, it loads perfectly and both button texts display perfectly.

        It works fine in Expression Blend as well. Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        J Offline
        J Offline
        jamie550
        wrote on last edited by
        #3

        I have no idea why I didn't begin using Blend a long time ago, for it is so much better in many cases. I think I'll never use the vs wpf designer again, except for editing xaml.

        M 2 Replies Last reply
        0
        • J jamie550

          I have no idea why I didn't begin using Blend a long time ago, for it is so much better in many cases. I think I'll never use the vs wpf designer again, except for editing xaml.

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          I generally use both VS and blend at the same time....I'm getting more and more used to which stuff works better on one or the other. It's frustrating though - I hate having to leave something out or do something different because something doesn't work in and/or crashes the designer(s). Mark

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          1 Reply Last reply
          0
          • J jamie550

            I have no idea why I didn't begin using Blend a long time ago, for it is so much better in many cases. I think I'll never use the vs wpf designer again, except for editing xaml.

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #5

            BTW, have you submitted this as a bug on Microsoft Connect? If not, I'll do it.... Cheers, Mark

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            J 1 Reply Last reply
            0
            • M Mark Salsbery

              BTW, have you submitted this as a bug on Microsoft Connect? If not, I'll do it.... Cheers, Mark

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              J Offline
              J Offline
              jamie550
              wrote on last edited by
              #6

              It looks like someone has already done it here.[^]

              M 1 Reply Last reply
              0
              • J jamie550

                It looks like someone has already done it here.[^]

                M Offline
                M Offline
                Mark Salsbery
                wrote on last edited by
                #7

                Cool. Marked as fixed too. Thank you :) Mark

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups