C# 코드에서 사각형 색상을 설정하려고합니다. 내가 이름을 가지고 왜 "네임 스페이스에 이름이 없습니다.
<phone:PhoneApplicationPage
x:Class="proba5.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:vm="clr-namespace:proba5"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<phone:PhoneApplicationPage.Resources>
<vm:colors x:Key="vmColors"/>
</phone:PhoneApplicationPage.Resources>
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid DataContext="{StaticResource vmColors}">
<Rectangle Fill="{Binding Gray}" />
</Grid>
</Grid>
</phone:PhoneApplicationPage>
colors.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace proba5
{
public class colors
{
public string Gray
{
set { }
get { return "#FF22262a"; }
}
}
}
: 다른 주제 도움말 날의 DataContext를 사용하지만, 클래스 색상과 키 vmColors
에서 MainPage.xaml
을 바인딩 할 수 없습니다 colors "네임 스페이스"clr-namespace : proba5 "에 존재하지 않습니다.
[이름 "XYZ"가 네임 스페이스 "clr-namespace : ABC"]에 존재하지 않음 (http://stackoverflow.com/questions/16216662/the-name-xyz-does-not-exist) -in-the-namespace-clr-namespaceabc) –