Bri*_*ing 8 wpf visual-studio-2010 visual-studio expression-blend 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 MyLogo : UserControl
{
public double Scale
{
get
{
return st.ScaleX;
}
set
{
st.ScaleX = value;
st.ScaleY = value;
}
}
public MyLogo()
{
InitializeComponent();
}
}
}
Run Code Online (Sandbox Code Playgroud)
在我的Navigation.xaml文件中,我有这个:
<UserControl x:Class="NamespaceX.NamespaceY.UI.UserControls.Navigation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:shape="clr-namespace:NamespaceX.NamespaceY.UI.Shapes"
Height="185" Width="1280" Loaded="UserControl_Loaded">
<FrameworkElement.Resources>
<ResourceDictionary Source="../Resources/Main.xaml" />
</FrameworkElement.Resources>
<Canvas>
<shape:MyLogo Scale="1.2" Height="181.483" Canvas.Left="38" Canvas.Top="4" Width="188" />
<StackPanel Canvas.Left="205" Canvas.Top="-2" Width="1062">
</StackPanel>
</Canvas>
Run Code Online (Sandbox Code Playgroud)
Bri*_*ing 17
这是解决方案.在应用程序的.csproj文件中,更改此:
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
Run Code Online (Sandbox Code Playgroud)
对此:
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Run Code Online (Sandbox Code Playgroud)
不要被Visual Studio在配置管理器中报告您在AnyCPU中运行的事实所迷惑.您必须手动编辑.csproj文件.
AMi*_*ico 10
它们与更改平台更改缓存的程序集有关.接受的答案是不可接受的.
这是我的建议:
受影响的XAML现在应该没有构建错误.
这适用于我,您的结果可能会有所不同.
| 归档时间: |
|
| 查看次数: |
22553 次 |
| 最近记录: |