0

我正在为一些好的 ole 客户端 Access\VBA 应用程序寻找继承人。LightSwitch 确实令人印象深刻,我决定认真尝试一下。我想要重现的东西之一是一个通用菜单,它允许自动选择周期并随后过滤日期数据。由于我们的大多数数据屏幕都包含日期,因此这种过滤工具是必须的:它使标准期间选择变得容易,然后可以在保持相同选择期间的屏幕之间切换(当然它比标准日期选择器更有效) .

它已被证明非常有效,并且是我们用户的最爱之一。

VBA\existing 菜单由 6 个组合控件组成,其中:

  1. 第一个列表框,标准周期当前\上一个\下个月\三个月\年等
  2. 减号和加号控件,自动将 1 个单位添加到 from\to 日期(单位取决于列表框中的值:如果选择了“month”,单击“+”将向 from\to 添加 1 个月到日期)
  3. 一个“从”和一个“到”日期框,我可以在其中看到选定的日期和\或手动更新它们的值
  4. “刷新”按钮

一般时期菜单

所以我不期待这里有一个完整的解决方案,但是,因为我绝对是 LightSwitch 的新手,并且仍然是 C# 初学者,所以我正在等待一些想法或建议。我想我必须创建一个自定义控件,但我必须承认我不知道从哪里开始。任何想法?

4

1 回答 1

1

Lightswitch has it's own way of doing things and it's own language for things that may not be obvious for a beginner. I'm going to use standard Lightswitch names for things. If you don't understand what something is, just ask and I'll elaborate.

You can implement this control using a combination of 6 standard controls as you did before.

The first would be a Choice List, a static list of values that presents as an AutoCompleteBox (i.e. a drop down). You would then edit the _Changed method of the Local Property used to create the Choice List. Inside that method, you would create a switch/case to set a TimeSpan type variable to the desired period.

The plus and minus would just be normal buttons. You would edit the _Execute methods of each to add/subtract the TimeSpan to/from the DateTime type Local Properties that represent the From and To dates. You will need to take special care here and probably use some intermediate variables as DateTime values are immutable.

The From and To dates can just be Local Properties of the type Date or DateTime as mentioned above. This will create a standard Silverlight Date Picker control which is quite nice.

date picker

The refresh would again just be a button that sets the Parameters of the Filter Query that you would use to display the Grid Control holding your data. That sequence of events is well represented in this question only you would be binding the Date properties instead of an AutoCompleteBox (i.e. drop down).

Hopefully that made sense and those links should point you in the right direction. I would also recommend Beth Massi's video series to get a good handle on the basic mechanics of a Lightswitch app. And you might want to consider making the application's code base in VB.NET. All the above still applies but the syntax may be slightly more familiar if you're coming from a VBA background.

于 2013-04-03T14:45:27.703 回答