c++ cli - [UWP][C++/CX] Cannot access XAML UI from codebehind -


c++:

#include "pch.h" #include "mainpage.xaml.h"  using namespace testing;  using namespace platform; using namespace windows::foundation; using namespace windows::foundation::collections; using namespace windows::ui::xaml; using namespace windows::ui::xaml::controls; using namespace windows::ui::xaml::controls::primitives; using namespace windows::ui::xaml::data; using namespace windows::ui::xaml::input; using namespace windows::ui::xaml::media; using namespace windows::ui::xaml::navigation;  mainpage::mainpage() {     initializecomponent(); }   void testing::mainpage::page_sizechanged(platform::object^ sender,windows::ui::xaml::sizechangedeventargs^ e) {     splitpane->ispaneopen = !splitpane->ispaneopen; //legal } void test()  {     splitpane->ispaneopen = !splitpane->ispaneopen; //not legal } 

xaml:

<page x:class="testing.mainpage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:testing" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:ignorable="d" sizechanged="page_sizechanged">  <grid background="{themeresource applicationpagebackgroundthemebrush}">     <splitview name="splitpane">     </splitview> </grid> 

so question why cant use reference or rather find reference of splitview in function? , there solution? find bit ugly pass splitpane parameter p.s. in c# test() legal

in order use private fields of mainpage, test() must method of mainpage class.

in mainpage.xaml.h:

public ref class mainpage sealed { public:     mainpage();     void test(); }; 

in mainpage.xaml.cpp:

void mainpage::test()  {     splitpane->ispaneopen = !splitpane->ispaneopen; // legal } 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -