c# - Unable to cast object of type 'Windows.UI.Xaml.Controls.Canvas' to type 'Canvas' -
i have canvas
, want name when tapped
. so, have xaml
:
<canvas name="drawline" ... > ... </canvas>
and function bind on tapped
event:
private void changepage(object sender, tappedroutedeventargs e) { string name = ((canvas)sender).name.tostring(); frame.navigate(typeof(params), name); }
bug following error:
an exception of type 'system.invalidcastexception' occurred in gotqn.exe not handled in user code
additional information: unable cast object of type 'windows.ui.xaml.controls.canvas' type 'gotqn.canvas'.
why ((canvas)sender).name.tostring();
generating such error? there other way name?
it seems have 2 canvas classes in different namespaces. guess windows.ui.xaml.controls
namespace not in using
code assuming gotqn.canvas
. did declare own canvas class? if yes, may have specify full name of canvas class want
string name = ((windows.ui.xaml.controls.canvas)sender).name.tostring();
Comments
Post a Comment