c# - Can't access Windows 8 Store user control from code -


i'm writing windows 8 store application , within i've designed own user control.

here code usercontrol (this dummy control problem exists this):

<usercontrol     x:class="windows8storetest.testusercontrol"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     xmlns:local="using:windows8storetest"     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"     mc:ignorable="d"     width="70"     height="40">      <stackpanel>         <button content="hello" foreground="pink" borderbrush="pink"/>     </stackpanel> </usercontrol> 

i've dropped user control onto page , give name:

<page     x:class="windows8storetest.mainpage"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     xmlns:local="using:windows8storetest"     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"     mc:ignorable="d">      <grid background="{staticresource applicationpagebackgroundthemebrush}">         <local:testusercontrol name="testcontrol"/>     </grid> </page> 

however, when go code behind can't access control name. doesn't seem exist! weird control doesn't exists within initializecomponent() method mainpage class why exist.

what missing user control?

i'm using windows 8 store, xaml, c#.

thanks in advance

try use this:

<local:testusercontrol x:name="testcontrol"/> 

should work...


Comments