How can I merge Blend with Visual Studio?

Pregunta How can I merge Blend with Visual Studio?

  • Wednesday, November 17, 2010 6:39 AM
     
     

    I am getting started with Silverlight 4. I have been creating cool stuff in Expression Blend 4 but now I feel like is time to take it to the next level. The issue is that I don't know how to "paste" my Expression Blend apps. into Visual Studio 10. I am working with navigation applications in VS and keeps throwing errors when I insert Blend xaml into VS xaml.

    If anyone knows where can I get some information about how to merge Blend with VS please add the links so I can get my work finally done.

    Thank you.

     

All Replies

  • Wednesday, November 17, 2010 8:35 AM
     
     

    What Errors do you get?

    There shouldn't be a problem by mergin Blend with VS.
    If I use Blend I first create a Solution in VS and then open it in Blend.

  • Wednesday, November 17, 2010 2:08 PM
    Moderator
     
     

    You should be able to right click your solution in Blend in the projects panel and select edit in visual studio, or just open the .sln file in visual studio. You can work with both programs open at once, just be sure to save all your files when you go from one app to the other so you don't lose any change.

    The errors you are seeing are probably because you have references that are missing in your VS project. Blend sometimes adds references to your project for you when you use certain functionality.

  • Wednesday, November 17, 2010 7:23 PM
     
     

    I want to reiterate what Chuck said because this is a common misconception I run into in my travels.  There is no such thing as "Blend XAML" versus "VS XAML": Blend and Visual Studio access and edit the exact same Solution, Projects, and Files.  The use of Blend does not introduce a single thing that cannot be consumed by Visual Studio.

    The majority of my development time is spent with both tools open simultaneously against the same Solution and I constantly toggle between the two tools.  In order to keep them in sync, I have formed the habit of Building (Ctrl+Shift+B in both tools) whenever I exit one or the other.  Doing so (or at least saving) will ensure that any changes made to relevant files will prompt you to update or reload the tool you are switching to: when you see that message box (in either tool) the answer should always be "Yes". I've been doing this since Blend V1 and only once have I lost data because I forgot to do this.

    It sounds like you are trying to copy XAML from Blend in one Solution to Visual Studio in another Solution, so I agree it is probably a missing reference, or possibly even a version issue where one solution is V3 and the other is V4.  To be sure you are in the same Solution, open your Solution in Expression Blend, then right-click the Solution in the Project tab and select "Edit in Visual Studio". 

    If you are using Events in Code Behind, you may also want to check your setting to edit in Visual Studio.  Go to Tools -> Options -> Project and make sure the box for "Use Microsoft Visual Studio (Standard or higher) to create and edit event handler code, if available".  This way, if you double click an event handler in Blend it will also open Visual Studio and take you to the event stub.


    -- Joel Cochran, MCTS (WinForms, WPF) Expression Blend MVP INETA Community Champion http://www.developingfor.net
  • Wednesday, November 17, 2010 11:50 PM
    Moderator
     
     
    Well said Joel!
  • Thursday, November 18, 2010 7:26 AM
     
     

    Thank you all for your responses.

    BAsically it's all about animations. Blend let us create animations without writing much code behind but when I tried to copy these files to a VS project I get errors such as missing references or assemblies.

    See below an animation project created in Blend 4(it shows only part of it). When I copy and paste this to VS still gives me an error even I am including all the references in my project properties and in my xaml assemblies.

    xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"

    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"

    <TextBlock x:Name="textBlock" Height="39" Margin="82,66,293,0" TextWrapping="Wrap" Text="SL Navigation App" VerticalAlignment="Top" FontSize="26.667" >
       <i:Interaction.Triggers>
        <i:EventTrigger EventName="MouseEnter">
         <ei:GoToStateAction StateName="MouseIn"/>
        </i:EventTrigger>
        <i:EventTrigger EventName="MouseLeave">
         <ei:GoToStateAction StateName="MouseOut"/>
        </i:EventTrigger>
       </i:Interaction.Triggers>
       <TextBlock.Foreground>
        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
         <GradientStop Color="#FF14BBD2" Offset="0"/>
         <GradientStop Color="#FF013C6C" Offset="1"/>
        </LinearGradientBrush>
       </TextBlock.Foreground>
      </TextBlock>

    In this case the "i:" and the "ei:" appears in VS as not part of the solution.

    Of course I can "edit in VS"  and yes it will open my project in VS but I am having issues trying to upload from here to my FTP server since the Web project originally in Blend is opened differently than a regular VS project.

    Also, do you guys know I good practical way to include projects or applications inside a Navigation Application? I am still researching on this and things are not so clear with pages and frames. BTW, Iam using Blend 4 and VS 2010.

    Hernan.

  • Thursday, November 18, 2010 2:46 PM
    Moderator
     
     

    If you get errors about those 2 namespaces, you are probably missing references to the proper assemblies from the Expression Blend SDK. If you look at your project in Blend, it will have references to:

    • Microsoft.Expression.Interactions.dll
    • System.Windows.Interactivity.dll
    Those are the 2 assemblies those namespaces refer to. Are those assemblies being referenced in your VS project?
  • Monday, December 10, 2012 6:05 PM
     
     

    Hi,

    i have the similar issue:

    i created an blend's solution (wpf graphic layout) and i need to combine/merge with an visual c# 2010 solution.. 

    Anyone knows how do I do that, pls?

  • Monday, December 10, 2012 9:00 PM
     
     

    If you right-click on a file in the projects panel, there will be an option to edit in VisualStudio. 

    Once selected, it simply opens VS and the project for you.

    A project created in VS can be opened in Blend and a project created in Blend can be opened in VS.

    or... If you are wanting to import the files created in Blend or VS into another project, simply open the project and import both the xaml and corresponding code-behind files.  You may have to go into both the xaml and code-behind and change the Namespace if it is different.

    ~Christine


    My Gallery - calControls

  • Monday, December 10, 2012 11:05 PM
     
      Has Code

    i knew that.. althought i do that, there are some mystic namespace/assemblies missing.

    Like this error

    Errore 1
    il tag 'BlockArrow' non esiste nello spazio dei nomi XML 'http://schemas.microsoft.com/expression/2010/drawing'. Riga 12, posizione 10.

    translated it's kinda like 

    Errore 1
     'BlockArrow' tag doesn't exist into XML namespace 'http://schemas.microsoft.com/expression/2010/drawing'. Riga 12, posizione 10.

    This is the visual c# file's header (after i pasted xaml code)

    <UserControl x:Class="neuroemotiv.UserControl1"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                 mc:Ignorable="d" 
                 d:DesignHeight="300" d:DesignWidth="300">


    instead, the header original blend's file I've made is

    <Window
    	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    	xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"
    	x:Class="Addestramento_2.MainWindow"
    	x:Name="Window"
    	Title="MainWindow"
    	Width="640" Height="480">

    how i do solve that?

    I tried to combine the both solutions (blend and visual c#) inside visual c#.. nothing to do. Doesn't work.

  • Monday, December 10, 2012 11:38 PM
     
     

    Did you add the Microsoft.Expression.Drawing.dll to your Refrences?

    In a test project, importing a window with a BlockArrow, I received the same error and it did not work until I added the dll and rebuilt

    Hope you get it worked out quickly and easily.

    ~Christine


    My Gallery - calControls

  • Tuesday, December 11, 2012 2:50 AM
     
     

    yuppy!!! Christine you are a miracle of evolution!! :) it's works! i was stuck on it since 1 week ! thank you so much!

    i followed also this

    <<That assembly is part of the Expression Blend SDK which is a free download:

    http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=75e13d71-7c53-4382-9592-6c07c6a00207

    Included in the install folder (which can be found here on your machine: C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\.NETFramework\v4.0) there are documents describing the redistribution license.>>

    from here
    http://social.expression.microsoft.com/Forums/zh/blend/thread/2fabb620-5c57-432d-8683-deee5ca7718f

    Anyway, I got a question:

    rather than copy and paste xaml code (achieved by blend) creating a new wpf in visual studio for opened solution.. is it possible, in some way, to link the two solutions (blend's solution & visual c#' solution) in order to work the both ?

    I mean:

    1. I'm working on a project visual c# -> it's means a visual c# solution 

    2. I'm working on blend to do graphics object and animation -> it's means a blend's solution 

    3. Into solution at 1. I created a form (form3) with element host like this pic

    like you see in explorer solution there are two solution 

    -addestramento it's the blend's solution that i loaded in visual c#

    -neuroemotiv it's visual c# solution and represent the main program of my project

    now, i'd like to select from ElementHost directly MainWindow.xaml (insted UserControl1 that contains xaml pasted from MainWindow.xaml and slightly edited adapted with right name of namespace) belongs from the blend's solution..

    why i can't do that?
    maybe exists some similar solution to do that?

    Thanks in advance


    • Edited by ludowanderlust Tuesday, December 11, 2012 2:55 AM add more info
    •  
  • Tuesday, December 11, 2012 5:47 AM
     
     

    Have you tried to open your solution in Blend?  I use Blend for design and VS for the coding so I am constantly switching back and forth.  I simply can't operate one without the other anymore.  And if you make changes in one with the other open, if you go back to the first you get a message that changes were made do you want to apply the changes.... just say yes.

    You can also Link to items.  I use linking with Resource Dictionaries and other projects contained within my solution.  Just right-click the project in the Blend Projects panel and select Link To Existing Item.  Be careful, Changes made to the link with change the original. 

    I thought the same feature was available in VS but I can't seem to find it.

    In the .toolbox, Specifically the Scenarios > Level 3 > Avatars lesson, I believe that is the correct one, they go over linking items.

    Right-Clicking the Refrences in Blend gives you the option of adding a project refrence as well a new refrence.  The project would have to be included in your solution for the option to be available.

    Did that answer your question?  I'm not sure I understand what you're saying with the last bit.

    ~Christine


    My Gallery - calControls

  • Tuesday, December 11, 2012 4:50 PM
     
     

    >Have you tried to open your solution in Blend? 

    >Right-Clicking the Refrences in Blend gives you the option of adding a project refrence as well a new >refrence.  The project would have to be included in your solution for the option to be available.

    yep, but I didn't know how to do working the two solution together.

    >I use Blend for design and VS for the coding so I am constantly switching back and forth.

    exactly, me too. 

    >In the .toolbox, Specifically the Scenarios > Level 3 > Avatars lesson,

    >I believe that is the correct >

    >one, they go over linking items.

    this "Scenarios > Level 3 > Avatars lesson" doesn't appear on my blend

    >I'm not sure I understand what you're saying with the last bit.

    maybe I didn't explain it/myself well.

    I try again:

    I'd like visual c# understand the presence of blend's solution and it let me selection blend's xaml file imported through the solution.