试图建立在WPF中查询生成器控制 [英] Trying to build a Query Builder Control in WPF

查看:232
本文介绍了试图建立在WPF中查询生成器控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请和我一起承担这个问题的长度,我试图尽可能描述。我是新来WPF程序。我基本上试图建立 RadDataFilter控制

Please bear with me for the length of this question, I tried to be as descriptive as possible. I am new to WPF programming. I am basically trying to build the RadDataFilter control:

RadDataFilter用于通过构建查询表达式过滤集合。该控制的一般的使用从数据库中把所有数据,然后过滤它们。

RadDataFilter is used to filter collection by building query expression. The control is generally used by bringing all data from the database and then filtering on them.

不过,我想用它来构建SQL查询表达式的然后的我查询数据库检索数据。公司拥有Telerik的产品许可证,所以我不得不尝试和使用控制。不幸的是,控制不灵活,我会想的自定义左下拉(radcombobox控件)。

However, I am trying to use it to build SQL query expression and then I query the database to retrieve the data. Our company has license for Telerik products so I had to try and use the control. Unfortunately, the control is not flexible to the extent that I would want to customize the Left Dropdown (RadComboBox).

由于我们有几个项目,用户可以筛选,这是行不通的为他们提供一个单一的dropdpwn。我想有一个自定义的控制,而不是下拉

As we have several items which users can filter on, it is not feasible to provide them with a single dropdpwn. I would like to have a custom control instead of the dropdown.

我有以下解决此问题的:

I have the following workaround to this problem:


  • 提取该控件模板和说明覆盖在我的XAML的此处。但是,这样做的inspite,我无法改变控制。我想这是由于我在WPF知识不足。

  • Extract the Template for that control and override it in my XAML as described here. However, inspite of doing this, I am unable to change the control. I assume it is due to my inadequate knowledge in WPF.

尝试更改Telerik的源代码(我们对代码的许可证也是如此)。但是这种方法,我们需要不断与每一次升级,这是球队高层维护变更。

Try to change the Source code for Telerik (We have the license for the code too). However with this approach, we need to keep making changes with every upgrade, which is high maintenance for the team.

尝试建立一个自定义的控制。

Try to build a custom control.

我要寻找的第3方法。如果有一个简单的方法(使用第2方案)或任何其他解决方案来实现这一点,请让我知道,我会尽力的。

I am looking for the 3rd approach. If there is an easy way (using the first 2 approaches) or any other solution to achieve this, please let me know and I shall try that.

要实现第三的方法,我想用一个TreeView用一个控件模板(包含我的自定义控件)每个节点。我将覆盖的ToString()自定义控制的方法,它给了我一个查询条件。一旦这样做,我将通过根节点建立最终的查询表达式的儿童进行迭代。

To implement the 3rd approach, I am thinking to use a TreeView with each node using a ControlTemplate (containing my Custom Control). I will override the ToString() method of the Custom Control that gives me the one query condition. Once done, I would iterate through the children of the root node to build the final query expression.

不过,我注意到,我们需要2个不同的CONTROLTEMPLATES(其中一个允许创建过滤器表达式和其他与经营者,类似于RadDataFilter)。我不知道如何设置这样的多个模板。

However as I notice, we need 2 different ControlTemplates (one which allows creating a filter expression and the other with the operator, similar to RadDataFilter). I do not know how to set multiple templates like this.

这听起来可能很简单的一些开发商在那里,但我真的很新的C#和WPF编程需要时间和经验是舒服。

This may sound simple to some of the developers out there, but I am really new to C# and WPF programming and would need time and experience to be comfortable with it.

请让我知道,如果你知道任何其他解决方案,我可以尝试解决这个问题。如果你觉得这是更好地创建自定义的控制,请指导我对最新最好的方式来实现这一点。在我的方法来创建自定义的控制也发表评论。

Please let me know if you know any other solution that I can try to solve this problem. If you feel it is better to create a custom control, please guide me on whats the best way to implement this. Also comment on my approach to create the custom control.

谢谢!

推荐答案

我解决它。采取第一种方式:

I resolved it. Took the first approach:

提取该控件模板和说明覆盖在我的XAML的这里

"Extract the Template for that control and override it in my XAML as described here.."

这篇关于试图建立在WPF中查询生成器控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆