locked
Setting Visibility property to one XAML Grid Object (C++)

    Question

  • I'm trying to do something that was supposed to be very simple and it is on C#, but when I try to use it on one C++ application, it is coming a night mare.

    I have on Grid component that I named as "AlignmentGrid", as showed bellow:

                           <Grid Name="AlignmentGrid" Margin="695,259,192,191" Grid.Column="1" Visibility="Collapsed">

     

    At runtime I need to show/hide this grid, so I tryed the follow on one button_click event:

     

     

    void SmartPrinter::PrinterControlPanel::AlignButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)

    {

           this->AlignmentGrid->Visibility = Visibility::Visible;

    }

     

    And it throws a compilation error:

    "error C2039: 'Visible' : is not a member of 'Windows::UI::Xaml::UIElement::Visibility'"

     

    The similar code runs without any problens on C#:

     

            void BackButton_Click(object sender, RoutedEventArgs e)

            {

                this.HeaderTitlePanel.Visibility = Windows.UI.Xaml.Visibility.Visible;

    }

     

    Could somebody save me? I'm coming crazy with this behavior. I'm not a very experienced C++ developer, but it seems to be one very simple code to be so wrong.

    • Edited by Leo Soares Thursday, December 22, 2011 1:21 AM
    Thursday, December 22, 2011 1:20 AM

Answers

  • Hi Leo,

    Try fully qualifying the Visibility class.  From the error it is finding Windows::UI::Xaml::UIElement::Visibility, but you want Windows::UI::Xaml::Visibility.

     

    void SmartPrinter::PrinterControlPanel::AlignButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
     
    {
           this->AlignmentGrid->Visibility = Windows::UI::Xaml::Visibility::Visible; 
    }
    
    


    --Rob

     

    • Marked as answer by Leo Soares Thursday, December 22, 2011 12:50 PM
    Thursday, December 22, 2011 2:27 AM
    Owner

All replies

  • Hi Leo,

    Try fully qualifying the Visibility class.  From the error it is finding Windows::UI::Xaml::UIElement::Visibility, but you want Windows::UI::Xaml::Visibility.

     

    void SmartPrinter::PrinterControlPanel::AlignButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
     
    {
           this->AlignmentGrid->Visibility = Windows::UI::Xaml::Visibility::Visible; 
    }
    
    


    --Rob

     

    • Marked as answer by Leo Soares Thursday, December 22, 2011 12:50 PM
    Thursday, December 22, 2011 2:27 AM
    Owner
  • Thank you Rob, that worked and will save me some time.

     

    But it is important to say that the page where the code was placed was not explicity "using" the namespace "Windows::UI::Xaml::UIElement" as you can see bellow, so the behavior don't make sense for me.

     

     

    using namespace SmartPrinter;

    using namespace Windows::Foundation;

    using namespace Windows::Graphics::Display;

    using namespace Windows::UI::ViewManagement;

    using namespace Windows::UI::Xaml;

    using namespace Windows::UI::Xaml::Controls;

    using namespace Windows::UI::Xaml::Data;

     

    Thursday, December 22, 2011 12:50 PM