WPF项目中缺少“在Expression Blend中打开...”

时间:2010-12-27 15:34:34

标签: wpf visual-studio expression-blend

我遇到了问题。当我创建一个WPF项目,并希望看到“打开”的链接 表达式混合“ - 它不像Silverlight项目那样。我可以使用”打开方式“链接获取混合,然后打开混合和工作从那里。(这是 解决)。然而,从互联网搜索我发现表达混合必须安装在visual studio之前(反之亦然),以便看到“打开表达式” 与wpf项目混合。这发生在Window 7 x64 OS和x32 ​​OS中。我也发现了 当使用“regedit”时,x64和x32在表达式混合方面的设置不同。

有人请帮助纠正这个问题。

1 个答案:

答案 0 :(得分:2)

似乎此功能根本不适用于WPF项目。当它工作时,它并不总是有效,它只适用于Silverlight项目。然而,“在Expression Blend中打开...”并不是很复杂,所以这里有一个Visual Studio宏来取代它。

Public Sub OpenInExpressionBlend()
    Dim blendPath As String = Nothing
    Dim key As String = "SOFTWARE\Microsoft\Expression\Blend\VS"
    Dim registryKey As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(key)
    If Not registryKey Is Nothing Then
        blendPath = registryKey.GetValue("BlendLaunchPath")
        registryKey.Close()
    End If
    If blendPath Is Nothing Then
        MsgBox("Cannot find Blend", MsgBoxStyle.Exclamation, "Open in Expression Blend")
        Return
    End If
    If DTE.SelectedItems.Count <> 1 Then
        MsgBox("Not just one item selected", MsgBoxStyle.Exclamation, "Open in Expression Blend")
        Return
    End If
    Dim item As SelectedItem = DTE.SelectedItems.Item(1)
    If Not TypeOf item.ProjectItem Is ProjectItem Then
        MsgBox("Not a project item", MsgBoxStyle.Exclamation, "Open in Expression Blend")
        Return
    End If
    Dim projectItem As ProjectItem = item.ProjectItem
    Dim project As Project = projectItem.ContainingProject
    Dim file As String = projectItem.Name
    If file.Substring(file.Length - 5) <> ".xaml" Then
        MsgBox("Not a xaml file", MsgBoxStyle.Exclamation, "Open in Expression Blend")
        Return
    End If
    While TypeOf projectItem.Collection.Parent Is ProjectItem
        projectItem = CType(projectItem.Collection.Parent, ProjectItem)
        file = projectItem.Name & "\" & file
    End While
    file = """" & file & """"
    Dim projectPath As String = """" & project.FullName & """"
    Dim blendArgs As String = projectPath & " /file:" & file
    Dim process As System.Diagnostics.Process = New System.Diagnostics.Process()

&安培; blendArgs)         process.Start(blendPath,blendArgs)     结束子

更新

要使用它,请使用宏IDE添加宏,然后将其添加到项目项上下文菜单中,如下所示:

  

工具 - &gt;自定义 - &gt;命令 - &gt;上下文菜单:项目和解决方案上下文菜单|项目 - &gt;添加命令... - &gt;分类:宏 - &gt;命令:Macros.MyMacros.Personal.OpenInExpressionBlend - &gt;行

     

修改选择 - &gt;名称:在Expression Blend中打开...

     

向下移动:(向下方打开......)

注意:该命令取决于您将其添加到哪个模块。