我在VS2010中有一個項目使用XAML,現在我需要將它加載到Expression Blend 4中。該項目在VS2010中生成並運行,這是第一個它已被加載到Blend中。即使成員不被識別,它也可以在Blend中構建和運行。將VS2010項目加載到Expression Blend時,屬性未被識別或無法訪問錯誤
爲什麼Scale屬性無法識別,爲什麼它在功能上工作時顯示爲錯誤?
EDIT雖然這樣構建並運行,但XAML不會在Blend中以圖形方式顯示,因此無法由非技術用戶修改。
在一些包含對用戶控件引用的.xaml文件的存在是不被混合與錯誤識別的屬性:
The member "XXXX" is not recognized or is not accessible
酒店在隱藏文件,並在代碼的.cs存在每種情況下的錯誤信息都是一樣的。
我已經看過很多在互聯網上可能的答案,但沒有一個是解決方案。引用的項目不是隻讀的。各種類和屬性都是公共的。我還將以下WPF引用添加到.csproj文件中,該文件缺失。
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
在以下代碼中,即使Scale屬性作爲用戶控件中的屬性存在,也無法識別。
這裏是MyLogo.xaml的用戶控件:
<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>
這裏是後面的代碼中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();
}
}
}
在我Navigation.xaml文件I有此:
<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>
此設置與上述錯誤無關。我的項目默認情況下在.csproj文件中有AnyCPU,並且我仍然面臨這個錯誤:) – balint 2012-07-10 13:08:58
是啊這與什麼有什麼關係? – 2012-09-09 16:55:59
無事可做,這怎麼可能被標記爲答案 – 2012-12-01 01:30:43