我正在尝试使用Blend 3.0来编辑包含一些WPF控件的项目.该项目已经从Visual Studio 2008编译并运行良好.
然而,在Blend中,我遇到了一些毫无意义的神秘错误:
例如,我有一个派生自Control的类:
namespace Company.WPFControls.SearchTextBox
{
public class SearchTextBox : Control
{
...
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试在同一个程序集中的资源中使用它来分配样式:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
xmlns:local="clr-namespace:Company.WPFControls.SearchTextBox"
<Style TargetType="{x:Type local:SearchTextBox}">
...
</Style>
</ResourceDictionary>
Run Code Online (Sandbox Code Playgroud)
我在Blend中收到以下错误:
名称"SearchTextBox"在命名空间"clr-namespace:Company.WPFControls.SearchTextBox"中不存在.
我已经尝试通过添加指定程序集名称,;assembly=Company.WPFControls
但它不会删除错误.
有没有办法解决这个问题,或者至少找出问题的来源?
在Expression Blend 4中,在编译时我收到错误说法
指定的解决方案配置"Debug | BNB"无效.请使用"配置和平台"属性指定有效的解决方案配置(例如,MSBuild.exe Solution.sln/p:Configuration = Debug/p:Platform ="Any CPU")或将这些属性留空以使用默认解决方案配置.
完成建筑项目"myproject.sln" - 失败.
构建失败.
我在这里开始提出一个问题:WPF将文件从Windows资源管理器拖放到TreeView上,但我发现这是一个完全不同的问题,我认为它是什么.
我有一个非常简单的测试用例.
我正在使用树视图,但如果我使用一个没有代码的简单列表框,只需使用以下xaml
<StackPanel Orientation="Vertical">
<ListBox Height="312" Background="#FFBDD6FF" AllowDrop="True"/>
</StackPanel>
Run Code Online (Sandbox Code Playgroud)
如果我在表达式混合中运行项目并在列表框上拖动一个文件,我会看到箭头和它下方的小方块,这可能会导致拖放.
如果我在visual studio中运行相同的项目并将文件拖到列表框上,我会得到一个带有一条直线的黑色圆圈.
我的计算机或代码可能导致什么问题?
wpf visual-studio-2010 wpf-controls visual-studio expression-blend-4
我在VS2010项目使用XAML,现在我需要将其加载到Expression Blend的4项目建立和运行VS2010,这是它已经被加载到混合的第一次.即使成员未被识别,它也可以在Blend中构建和运行.
为什么Scale属性无法识别?为什么它在功能上有效时会显示为错误?
编辑虽然这构建和运行,但XAML不会在Blend中以图形方式显示,因此非技术用户无法修改.
在许多包含对usercontrols的引用的.xaml文件中,Blend无法识别出错误的属性:
The member "XXXX" is not recognized or is not accessible
Run Code Online (Sandbox Code Playgroud)
该属性存在于.cs代码隐藏文件中,并且在每种情况下错误消息都是相同的.
我在互联网上看了很多可能的答案,但没有一个是解决方案.引用的项目不是只读的.各种类和属性都是公共的.我还将以下WPF引用添加到.csproj文件中,该文件丢失了.
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Run Code Online (Sandbox Code Playgroud)
在以下代码中,即使Scale属性作为用户控件中的属性存在,也无法识别它.
这是MyLogo.xaml中的UserControl:
<UserControl x:Class="NamespaceX.NamespaceY.UI.Shapes.MyLogo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="132" Width="105">
<Canvas>
<Canvas.LayoutTransform>
<ScaleTransform x:Name="st" CenterX="0" CenterY="0" />
</Canvas.LayoutTransform>
<Image Source="/Client;component/Images/MyLogo.png"/>
</Canvas>
Run Code Online (Sandbox Code Playgroud)
以下是MyLogo.xaml.cs中的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace NamespaceX.NamespaceY.UI.Shapes
{
/// <summary>
/// Interaction logic for MyLogo.xaml
/// </summary>
public partial class …
Run Code Online (Sandbox Code Playgroud) wpf visual-studio-2010 visual-studio expression-blend expression-blend-4
我在VS 2010中创建了我的WPF项目.在完成功能GUI的工作后,我想在Blend 4中编辑我的控件模板.但是当我在Blend中打开项目时,在DesignMode中,他告诉我
无效的XAML
在结果窗口中,他写道:
Windows Presentation Foundation(WPF)项目不支持[ControlName]
其中[ControlName]是我在项目中使用的默认控件列表(例如Window,DockPanel等)
如何避免这个问题,并能够在Expression-Blend4的DesignMode上编辑WPF表单?
编辑:
可能的解决方法.
在对由Blend
(由Studio
我们创建的)空项目(*.csproj文件)进行一些比较之后,我发现VisualStudio
用下一行创建它:
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
...
Run Code Online (Sandbox Code Playgroud)
而Blend使用以下行:
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Run Code Online (Sandbox Code Playgroud)
因此,如果您更改x86
为AnyCPU
,Blend将按预期打开项目.
wpf projects-and-solutions visual-studio-2010 expression-blend-4
我是开发更大规模的Silverlight 4项目的一部分,我们将有一组符号,应该在GUI的不同部分使用(参见下面的示例).
这些图标直接在Blend中由多个路径构成,可以单独使用,也可以在用户控件中使用不同的视觉状态(在多个上下文中使用相同的图标).为了便于更改单个图标的设计,并使其在整个应用程序中传播,存储这些图标的最佳方法是什么?
我尝试从它们创建样式(右键单击 - >编辑样式..),但这只允许我创建一个空样式,没有任何路径数据.手动将包含路径的网格的xaml代码放入字典中也没有帮助,我缺少什么?
如何以简单的方式保存路径和样式(颜色,笔触,填充等)信息,最好是在资源字典中,这样我可以轻松地在用户控件和其他地方重用它们,同时保持简单的更新?
我正在尝试重用的图标示例:
我正在尝试添加对另一个项目(例如Elysium)中定义的资源库的引用,并在表达式混合中使用它.
以下是我在App.Xaml文件中合并资源字典的方法.
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro.Resources;component/Icons.xaml" />
<ResourceDictionary Source="pack://application:,,,/Telerik.Windows.Themes.Metro;component/Themes/System.Windows.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Run Code Online (Sandbox Code Playgroud)
但我似乎无法在Expression Blend 4中获得这些库中定义的任何画笔资源.任何想法?
短版本 如何处理嵌入到其他窗口/用户/自定义控件中的UserControl中的静态资源查找?因此,Blend 4可以正确地呈现它@设计时Visual Studio已经为您做的事情.
长版本 正如问题所示,我们有一个窗口,其中包含一些嵌入式用户控件,窗口以及每个嵌入式用户控件都使用静态资源标记扩展来解析对app.xaml文件中合并字典中找到的资源的引用.
当单独打开时,Blend在加载和渲染我在VS Designer Surface中创建的任何示例用户控件时都没有问题.解决我无处不在的无数静态资源标记扩展没有问题.
每当我尝试打开我的'MainWindow.xml'时,(一个窗口控件)我注意到我得到4 - 无法使用Blend 4 创建类型错误实例,很好地告诉我ArtBoard它已经捕获了一些设计时异常.通过将VS调试器实例附加到Blend进一步深入研究这些异常我注意到我引用的每一个静态资源,它抱怨它无法找到它.
作为比较,我查看了我创建的自定义控件,它根本不使用任何静态资源,而是使用本地资源.嵌入到我注意到的UserControl中的这个自定义控件非常好用.我觉得很明显为什么!
在SO上有任何人,有任何想法如何解决这个问题?我尝试了整个'添加设计时字典'< - 部分工作,嵌入式用户控件仍然根本没有创建!
研究
更新:可能的解决方案:
这些解决方案都不是很漂亮.=(
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
x:Class="MPS.Window1"
x:Name="Window"
Title="Window1"
Width="640" Height="480">
<Window.Resources>
<ControlTemplate x:Key="bs" TargetType="{x:Type xctk:ButtonSpinner}">
<Grid SnapsToDevicePixels="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Border x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.ColumnSpan="2"/>
<ContentPresenter Content="{TemplateBinding Content}" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
<Grid Grid.Column="1" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.Visibility>
<TemplateBinding Property="ShowButtonSpinner">
<TemplateBinding.Converter>
<BooleanToVisibilityConverter/>
</TemplateBinding.Converter>
</TemplateBinding>
</Grid.Visibility>
<RepeatButton x:Name="PART_IncreaseButton" IsTabStop="{TemplateBinding IsTabStop}" Style="{DynamicResource Xceed.Wpf.Toolkit.Themes.StaticResourceKey}">
<RepeatButton.ContentTemplate>
<DataTemplate>
<Path Data="M0,3C0,3 0,4 0,4 0,4 3,4 3,4 3,4 3,3 3,3 …
Run Code Online (Sandbox Code Playgroud) 我在我的项目中使用来自 NuGet的Extended WPF Toolkit Community Edition v2.6,但我不知道我是否应该做更多的事情来允许我设置主题或自定义控件模板。
在要求 Designer/Blend 为 PropertyGrid 控件创建现有默认模板的副本后,UI 已损坏。模板看起来正确,但在设计时或运行时不再起作用。
选择将默认模板复制到新的样式后:
有没有一种简单的方法来编辑此控件的内置样式?我真的只是想覆盖 PropertyGrid 的编辑器/标签的前景色/背景色。
我在 XAML 中尝试了一些手动戳,但成功有限:
<Style TargetType="{x:Type xctk:DropDownButton}">
<Setter Property="Background" Value="Black"/>
<Setter Property="Foreground" Value="White"/>
</Style>
<Style TargetType="{x:Type xctk:CustomPropertyItem}">
<Setter Property="Background" Value="Black"/>
<Setter Property="Foreground" Value="White"/>
</Style>
<Style TargetType="{x:Type xctk:PropertyGridEditorCollectionControl}">
<Setter Property="Background" Value="Black"/>
<Setter Property="Foreground" Value="White"/>
</Style>
Run Code Online (Sandbox Code Playgroud)
尝试创建属性容器样式时,通过复制默认值,我得到“复制样式失败”。VS Designer 或 Blend 中的错误。
结果如下:
我已经尝试手动包含 Xceed Toolkit 程序集中的 generic.xaml,但它没有解决问题。
我尝试了两种引用资源的方法:
<ResourceDictionary Source="/Xceed.Wpf.Toolkit;component/themes/generic.xaml" />
<ResourceDictionary Source="pack://application:,,,/Xceed.Wpf.Toolkit;component/Themes/generic.xaml">
Run Code Online (Sandbox Code Playgroud)
这是我尝试设置 PropertyContainerStyle 时来自设计器的堆栈跟踪:
C:\ Program Files\MSBuild\Microsoft\Silverlight for Phone\v4.0\Microsoft.Silverlight.Common.targets(625,5):错误RG1000:未知的构建错误,'已添加具有相同键的项目. "
完成构建项目"FileName.csproj" - 失败.
构建失败.
每当我尝试构建soln时都会收到此错误.
我在XAML可视化树中有一些图像.我想显示一个设计时图像,这样我就可以检查布局,尺寸等等.这相当于:
<UserControl.Resources>
<Something x:Key="DesignSource" Uri="/Image/sourceimage.png"/>
</UserControl.Resources>
<Image
Source="{Binding RealSource}"
d:Source="{StaticResource DesignSource}"/>
Run Code Online (Sandbox Code Playgroud)
其中"某些东西"是某些图像源提供者指向某个图像文件,而"d:Source"只是为了显示我的意图:同时定义不同的源:一个用于运行时,另一个用于设计时.
欢迎在XAML或SampleData(Blend)中使用DataProviders(我知道它们存在,但不知道如何包含图像).
我是Silverlight的新手,我想在故事板finsihes或结束时触发.我将如何继续这样做.我已经在鼠标输入的故事板中有一个触发器.我不确定我是否可以在那里添加更多活动.谢谢
wpf ×8
xaml ×2
blend ×1
blendability ×1
c# ×1
c#-4.0 ×1
design-time ×1
propertygrid ×1
silverlight ×1
wpf-controls ×1