Access the value of button and checkbox of an XAML in other another class in a wpf c# application

隐身守侯 提交于 2019-12-02 11:47:40

Without seeing the complete KinectWindow.xaml file or downloading the SDK I'm taking a bit of a guess, but it seems to me that your problems are caused by having two different instances of KinectSkeleton:

  • ks that you're instantiating in KinectWindow, setting its is_checked property and calling setcurrentdt
  • the one declared somewhere in KinectWindow.xaml in which OnRender is being called.

How to fix this problem?

  • Find KinectSkeleton in KinectWindow.xaml. It should be defined like this (instead of local, a different namespace prefix could be used):
<local:KinectSkeleton ... />
  • Give it a name so that you can reference it from code behind in KinextWindow.xaml.cs by adding the x:Name attribute. If you name it ks you won't need to change your existing code modifications:
<local:KinectSkeleton x:Name="ks" ... />
  • Delete your declaration of KinectSkeleton class in code behind to prevent the clash:
public KinectSkeleton ks = new KinectSkeleton();

Now you will have only a single instance of KinectSkeleton, therefore OnRender will work with the same data that you're modifying from your event handlers.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!