locked
How to add other controls within User Controls RRS feed

  • Question

  • Hi all,

    I'm just doing my 1st steps with Expression Blend and I am experiencing the following problems with User Controls.

    I want to create a user control With a predefined border & background and a StackPanel inside. Then, when using instances of this new User Control, it should be possible to add futher control to these instances.

    I tried quite a lot but it seems not to be possible, to add additional controls to these instances. I can add instances of my new user control to my project, but whenever I want to place another control inside of such an instance, the control is always place somewhere outside!

    Do I get something wrong? What do I have to do to accomplish just want i want?

    Any help is greatly appreciated

    Michael

     

    Monday, March 29, 2010 6:45 AM

All replies

  • Hi Snnoopy,

                         I am not 100% sure if I understand your question but you can easily add other controls inside your UserControl. What you have to do is to right click on the instance of UserControl and click "Edit Control". Then you can modify the actual UserControl by adding new controls or changing properties. On Build Blend will then update all instances of these UserControls on the design surface.

    Hope this helps.

    --Navit Saxena

    Monday, March 29, 2010 7:36 AM
  • Hi Navit,

    No, that's not exactly what I want. I want to create UserControls with certain "base" properties and use instances of these "Base" controls later on to create the application. Let me give you an example.

    I want to have a UserControl U1 where certain properties are predefined like:
     - A special border with special border brushes
     - A special background brush
     - A special panel inside that describes how to lay out all the additional controls

    Then I want to create different instances of this UserControl say U1a and U1b by dragging and dropping my UserControl U1 into the layout. Now I want to place other controls into each of the 2 instances by draggig an dropping them into U1a and/or U1b, for example:

    U1a
     -- Button1
     -- Button2
     -- CheckBox1
     -- Chekcbox2

    U1a
     -- Button3
     -- Radiobutton1
     -- Radiobutton2
     -- Border1
         -- StackPanel
     -- Border2
     -- U2a (an instance of an other, different UserControl)

    It also should be possible to nest different UserControl within each other. So, my UserControls should give me a set of controls I can use to build the applications. I am unsure, if this is the correct approach because I'm fairly new to all this stuff and just want to know what Expression Blend can and where the limitations are. We intend to switch to .NET and also want to give our applications a new, unique and company wide look and feel. Probably you know, which is the best method to accomplish what we want and also can give me a tip or a link wher I can find the information I'm looking for.

    Thank you very much in advance.

    Michael

     

     

    Monday, March 29, 2010 9:02 AM
  • There should be no problem. What you have to do ist to put the Usercontrols in the UserControl in a General-Control
    like a StackPanel, Grid.

    So your Code should look like
    U1a
    -- Grid
    ----RadioButton1
    ----RadioButton2
    ----Border
    ------StackPanel
    --------etc...

     

    Monday, March 29, 2010 11:59 AM
  • Hi Stef,

    I've already exactly done this but the designer still refuses to let me drag & drop another (standard) control into my UserControl.. But in the meantime I've found a thread discussing a similar matter where a gentlemen has written the following:

     

    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    We have explicitly disabled drag and drop into UserControls (and anything
    derived from UserControl). If you were to change the base of the markup to
    be Button (so that the Control you are defining derived from Button), I
    would expect things to work.
    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    Now, I am completely confused. Is it possible or is a limitation by design?

    Michael

    Monday, March 29, 2010 12:44 PM
  • I think the Limitation is only in the Drag & Drop.
    Did you tried to create the Controls by adding them inthe XAML-sourcecode?

    Tuesday, March 30, 2010 6:27 AM
  • Hi Stef,

    No, I haven't tried that because it's not what we want. We don't want to do the graphical design work by our own and contract a graphical design office with that and I don't beleive, the guys there know what XAML is much less they cannot work with XAML.

    Wednesday, March 31, 2010 5:41 AM