Windows :: UI :: Xaml :: HorizontalAlignment与Windows :: UI :: Xaml :: FrameworkAlignment :: HorizontalAlignment [英] Windows::UI::Xaml::HorizontalAlignment versus Windows::UI::Xaml::FrameworkAlignment::HorizontalAlignment
问题描述
由于HorizontalAlignment实际上是我有一个using语句的Windows :: UI :: Xaml的成员,我很困惑为什么
HorizontalAlignment :: Center产生以下编译器错误:
blankpage.xaml.cpp(43):错误C2039:'中心':不是'Windows :: UI :: Xaml :: FrameworkElement :: HorizontalAlignment'的成员
使用命名空间Windows :: UI :: Xaml;
void BlankPage :: OnNavigatedTo(NavigationEventArgs ^ e)
{
TextBlock ^ dynTextBlock = ref new TextBlock();
dynTextBlock-> Text =" dynTextBlock动态创建" ;;
dynTextBlock-> HorizontalAlignment = Windows :: UI :: Xaml :: HorizontalAlignment :: Center;
dynTextBlock-> HorizontalAlignment = HorizontalAlignment :: Center;
myGrid-> Children-> Append(dynTextBlock);
}
// Intellisense显示Windows :: UI :: Xaml :: HorizontalAlignment和Windows :: UI :: Xaml :: FrameworkAlignment :: HorizontalAlignment
< span style ="font-size:small"> // for dynTextBlock->水平对齐
Hello,
我认为编译器将HorizontalAlignment视为FrameworkElement。 HorizontalAlignment属性
所以你需要添加它的整个路径。
祝你好运,
杰西
Since HorizontalAlignment is in fact a member of Windows::UI::Xaml to which I have a using statement, I'm puzzled why
HorizontalAlignment::Center produces the following compiler error:
blankpage.xaml.cpp(43): error C2039: 'Center' : is not a member of 'Windows::UI::Xaml::FrameworkElement::HorizontalAlignment'
using namespace Windows::UI::Xaml; void BlankPage::OnNavigatedTo(NavigationEventArgs^ e) { TextBlock^ dynTextBlock = ref new TextBlock(); dynTextBlock->Text= "dynTextBlock created dynamically"; dynTextBlock->HorizontalAlignment= Windows::UI::Xaml::HorizontalAlignment::Center; dynTextBlock->HorizontalAlignment= HorizontalAlignment::Center; myGrid->Children->Append( dynTextBlock ); }
// Intellisense displays Windows::UI::Xaml::HorizontalAlignment and Windows::UI::Xaml::FrameworkAlignment::HorizontalAlignment
// for dynTextBlock->Horizontal alignment
Hello,
I think the complier treat HorizontalAlignment as the FrameworkElement.HorizontalAlignment property
So that you need to add the whole path of it.
Best regards,
Jesse
这篇关于Windows :: UI :: Xaml :: HorizontalAlignment与Windows :: UI :: Xaml :: FrameworkAlignment :: HorizontalAlignment的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!