简体   繁体   English

Windows Phone 8中的用户控件属性

[英]User control property in windowsphone 8

I am planning on making a custom user control for Windows Phone 8. But what I want to make is a connection to a PLC and i don't want the user control to be visible on any page. 我打算为Windows Phone 8创建自定义用户控件。但是,我要建立的是与PLC的连接,并且我不希望用户控件在任何页面上都可见。 I want the control to act like for example a timer in Windows Forms (so it is there, but not visible). 我希望控件的行为类似于Windows窗体中的计时器(因此它存在,但不可见)。

Also, i would like to add custom properties to my control that you can edit using the properties window in vs. How do i accomplish such thing? 另外,我想将自定义属性添加到控件中,您可以使用vs中的属性窗口进行编辑。我该如何完成此任务?

I have read much information on the subject, but everything seems to create a visible control. 我已经阅读了很多有关该主题的信息,但是一切似乎都可以创建一个可见的控件。 And create properties that are set in xaml. 并创建在xaml中设置的属性。 Those are both things i don't want. 这些都是我不想要的东西。

Then why do you want to create a custom control if it is not going to have a visual representation? 那么,如果不具有视觉表示,为什么还要创建一个自定义控件呢? Why can't you simply create a ordinary class with normal properties and events and use it instead? 为什么不能简单地创建具有常规属性和事件的普通类并使用它呢?

That is what classes are for - encapsulating the logic in a structured way. 这就是类的用途-以结构化的方式封装逻辑。

If you want a visual control, you create user controls. 如果需要可视控件,则可以创建用户控件。 Otherwise, a class will suffice. 否则,一堂课就足够了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM