UserControl & Blend 2.5
Last post 05-29-2008 5:07 PM by Torres180791. 9 replies.
Sort Posts:
03-08-2008 4:51 PM
UserControl & Blend 2.5

I am trying to design a UserControl in Blend 2.5.

I am having some difficulty because I want my UserControl to be properly resizable when you drop it into a Page. If you set the Width/Height to auto, or remove it from the XAML in the designer the user control is pretty much 0 size and you can't see anything that you've put inside it. If you set it to 300,300 then now in the Page when you resize your UserControl it always resets to 300 pixels.

 How are we supposed to edit our UserControls in blend to give them a visual look?

Any help would be greatly appreciated.

Thanks and take care.

synced

Loading...
Joined on 07-08-2004
Posts 116
03-09-2008 3:19 AM
Marked as Answer
Re: UserControl & Blend 2.5

Hi,

There are 2 ways you could do this:

  1. Set MinWidth or MinHeight - this will enforce a minimum size for your control (both at design time and run time)
  2. Set d:DesignWidth and DesignHeight - this will enforce a size only at design time (in order to use design time properties, you also need the following namespace declarations (you can get them inserted automatically in Blend by locking than unlocking an object from the timeline)

xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"

Here is an example:

<UserControl
 xmlns="http://schemas.microsoft.com/client/2007"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 mc:Ignorable="d"
 x:Class="SilverlightApplication1.UserControl1"
 d:DesignWidth="100" d:DesignHeight="100">

 <Grid x:Name="LayoutRoot" Background="White" >

 </Grid>
</UserControl>

Thanks,
- Adrian

- Adrian Vinca [MSFT]
Content is provided "AS IS" with no warranties and confers no rights.
Opinions are my own and do not represent those of my employer.

Adrian Vinca

Loading...
Joined on 03-06-2008
Redmond, WA
Posts 14
04-02-2008 11:35 AM
Re: UserControl & Blend 2.5

Hi!

 I have the same problem, my UseControl no display in design mode and runtime mode!

This is my test code:

<UserControl

xmlns="http://schemas.microsoft.com/client/2007"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

mc:Ignorable="d"

x:Class="Webcasts.UserControl1"

d:DesignWidth="100" d:DesignHeight="100">

<Grid x:Name="LayoutRoot" Background="White" MinWidth="100" MinHeight="100">

<Rectangle HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Fill="#FFFFFFFF" Stroke="#FF000000"/>

</Grid>

</UserControl>

So, when I paste this UserControl in my page (in Expression Blend 2.5), then launch my page in debug mode I get the exception:  "Unknown element: UserControl".

What the problem?

Tuizi

Loading...
Joined on 12-20-2007
Posts 88
04-02-2008 11:43 AM
Re: UserControl & Blend 2.5

Tuizi:

xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

mc:Ignorable="d"

 

What is this?

I have only this.

<UserControl
    xmlns="http://schemas.microsoft.com/client/2007"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="SilverlightApplication3.Page"
    Width="640" Height="480">

    <Grid x:Name="LayoutRoot" Background="White" />
</UserControl>

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Blog : http://michaelsync.net
Feed : http://michaelsync.net/feed

mchlSync

Loading...
Joined on 09-16-2005
Singapore
Posts 2,335
04-02-2008 11:49 AM
Re: UserControl & Blend 2.5

This code is automatically generated by EB 2.5 for me!

I try to remove it, but that don't resolve my problem. Crying

Tuizi

Loading...
Joined on 12-20-2007
Posts 88
04-11-2008 2:29 PM
Re: UserControl & Blend 2.5

So my problem was some UserControl's I created first in VS2008 and some I created initially in Blend. This results in 2 different default XAML files and the Blend one includes the designer sizes specified. VS2008 *really* needs to act the same or else you open it in Blend and set the width/height to auto and bam you have an unusable workspace.

Unless you go modify the XAML manually but I believe the point of Blend is to make an intuitive design environment. Please make them behave the same!

synced

Loading...
Joined on 07-08-2004
Posts 116
04-11-2008 4:34 PM
Re: UserControl & Blend 2.5

Hi everybody,

I will try to shed some light into what design time size means.

I will start by talking a little bit about the Expression Blend design time properties. The design properties are some special properties used only by Expression Blend when editing a specific file. For example, when you use the "lock" button in the timeline, Expression Blend will set such a property: d:IsLocked="True". These properties are defined in the xmlns:d namespace. The corresponding namespace declarations get inserted in the xaml when such a property is needed.

The design time properties can be safely ignored by other tools and they are ignored at the runtime (mc:Ignorable specifies that the namespace with the "d" prefix can be ignored).

 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 mc:Ignorable="d"

Expression Blend uses two design time properties (d:DesignWidth, d:DesignHeight) to specify a size for a control to be used at design time. This allows you to edit a control which has an auto size at runtime. Unfortunately, Visual Studio doesn't currently support the design time size (but you can specify Width/Height or MinWidth/MinHeight to enforce a size or minimum size so that the control won't be displayed as 0 size). 

How to set the design time property: If the size of your user control is Auto (it doesn't have Width or Height), Expression Blend displays a special resize adorner, which will set/modify the design time size.

 Hope this helps,

-Adrian

- Adrian Vinca [MSFT]
Content is provided "AS IS" with no warranties and confers no rights.
Opinions are my own and do not represent those of my employer.

Adrian Vinca

Loading...
Joined on 03-06-2008
Redmond, WA
Posts 14
05-17-2008 10:37 PM
Re: UserControl & Blend 2.5

 

Apologies if this question fits better in another forum.

When programming SL Beta 1 with C#, is it possible for a UserControl to know that it is being displayed in Design Time and draw itself differently than it would at runtime? I am writing a control that gets images from the web and I would prefer not to have it download the images during design time.

Thanks for any help on this.

ercercerc

Loading...
Joined on 06-24-2007
Posts 35
05-26-2008 1:16 PM
Re: UserControl & Blend 2.5

Just as a consistency note. I ran into these issues because sometimes the UserControl was created from VS and sometimes Blend. Which in some cases meant no design-specific attributes being default created and making the environment unfriendly.

So far I am not too happy about the amount of "XAML" a designer must be aware of to shoehorn things to work. I hope issues like this get resolved so the designer can touch as minimum amount of XAML or ideally no XAML as possible.

synced

Loading...
Joined on 07-08-2004
Posts 116
05-29-2008 5:07 PM
UserControl & Blend 2.5
I've got a question: In Blend i'm all the time trying to change user controls: The Problem is: when i change one user control, all of them get the property i changed and i cant just rename one. Does anybody know a solution? Thanks for helping!
Torres180791

Loading...
Joined on 05-29-2008
Posts 2
Page view counter