Windows::UI::Xaml::HorizontalAlignment versus Windows::UI::Xaml::FrameworkAlignment::HorizontalAlignment RRS feed

  • Question

  • 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

    Monday, May 21, 2012 10:33 PM

All replies




    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 Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Tuesday, May 22, 2012 6:31 AM
  • I can work around it, but I still don't understand WHY the compiler trys to resolve HorizontalAlignment::Center



    instead of


    when there is a

    using namespace Windows::UI::Xaml;


    Tuesday, May 22, 2012 1:45 PM
  • The behavior you were expecting, exists when using C#.

    I'm also seeing the unexpected behavior you reported applies to all the enum types I've tried so far in the Windows::UI::XAML namespace.

    Could you please file a Visual Studio bug on this issue please? Let me know if you do not, so I can create one on your behalf. VS 20111 Bug form

    David Lamb

    Wednesday, May 23, 2012 6:25 PM
  • We can skip the bug report because I just applied the latest updates to VS11 Beta:

    Microsoft Visual Studio 11
    Version 11.0.50323.1 QRELB
    Microsoft Visual C++ 11 Beta   04167-115-2600346-58856

    and now the below line compile correctly and Intellisense is aware too.

    dynTextBlock->TextAlignment= TextAlignment::Right;
    • Marked as answer by Andrew7Webb Friday, June 1, 2012 2:20 AM
    • Unmarked as answer by Andrew7Webb Saturday, June 2, 2012 2:36 AM
    Wednesday, May 23, 2012 7:42 PM
  • I filled out a bug report because the problem may have regressed in the release candidate VS


    I get the compiler error:

    error C2039: 'Center' : is not a member of 'Windows::UI::Xaml::FrameworkElement::HorizontalAlignment'


    MyStackPanel->HorizontalAlignment=                    HorizontalAlignment::Center;

    • Proposed as answer by Jesse Jiang Wednesday, June 6, 2012 9:25 AM
    Saturday, June 2, 2012 3:08 AM