在 silverlight 中使用自动完成框?

发布于 2024-11-04 10:55:47 字数 198 浏览 7 评论 0原文

我当前正在 Telerik 的 radgrid 控件中显示数据,我想在名为“Name”的列上添加一个自动文本框。我该怎么做?

我的 radgrid 仅显示数据,我希望每当用户输入文本框时都会弹出一个名称列表,就像在 stackoverflow 网站中一样。

请帮助..我一直在使用 silverlight、wcf ria 服务、telerik 控件。

i am currently displaying data in the radgrid controls of telerik, i want to add an autotextbox over the column named "Name". how can i do this?

my radgrid only displays data and i want that whenever user enters into textbox a list of name pops up just like in stackoverflow web site.

please help..i have been using silverlight,wcf ria services,telerik controls.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云雾 2024-11-11 10:55:47

您可以使用 Silverlight 4 Toolkit 中的自动完成文本框。该工具包是一组高级控件,不属于核心 Visual Studio 库的一部分。下载&安装后,您可以前往此处。安装完成后,添加对 System.Windows.Controls 的项目引用,并将其添加到 UserControl 声明中:

xmlns:input="clr-namespace:System.Windows.Controls; assembly=System.Windows.Controls。输入”

这为您提供了 Silverlight 工具包的参考点,特别是输入控件。完成后,以下是使用自动完成文本框的示例:

这直接来自 Silverlight Toolkit 的文档。 链接此处。单击左侧菜单中的“自动完成框”(标题下:“输入”)。加载后,您可以通过单击窗口底部的任意一项来查看 XAML/C#,例如“AutoCompleteBoxSample.xaml”或“AutoCompleteBoxSample.xaml.cs”,这将为您提供开始/代码。正在寻找。

在您的情况下,您还需要为 radgridview 创建一个单元格模板。以下是其外观的快速示例:

<radControls:RadGridView x:Name="registerGridView" 
                             AutoGenerateColumns="False">  
        <radControls:RadGridView.Columns> 
            <radControls:GridViewToggleRowDetailsColumn /> 
            <radControls:GridViewDataColumn Header="Client" /> 
            <radControls:GridViewDataColumn Header="Site" />  
            <radControls:GridViewDataColumn Header="Name">  
                <radControls:GridViewDataColumn.CellTemplate> 
                    <DataTemplate> 
                        <StackPanel Orientation="Horizontal">  
                            <input:AutoCompleteBox HorizontalAlignment="Left" ItemsSource="{Binding Names}" SelectionChanged="OnSelectionChanged"/>
                        </StackPanel> 
                    </DataTemplate> 
                </radControls:GridViewDataColumn.CellTemplate> 
            </radControls:GridViewDataColumn> 
        </radControls:RadGridView.Columns> 
    </radControls:RadGridView> 

You can use the AutoComplete textbox from the Silverlight 4 Toolkit. The toolkit is an advanced set of controls that are not part of the core Visual Studio library. To download & install, you can head here. Once you have it installed, you add a project reference to System.Windows.Controls add this to your UserControl declaration:

xmlns:input="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input"

This gives you a reference point for the Silverlight Toolkit, specifically the input controls. Once that's done, here is an example of using the autocomplete textbox:

<input:AutoCompleteBox IsTextCompletionEnabled="False" HorizontalAlignment="Left" ItemsSource="{StaticResource SampleEmployees}" SelectionChanged="OnSelectionChanged"/>

This comes directly from the documentation from the Silverlight Toolkit. Link here. Click the 'AutoCompleteBox' in the left menu (under heading: Input). Once loaded, you can view the XAML/C# by clicking on any one of the items at the bottom of the window, such as 'AutoCompleteBoxSample.xaml' or 'AutoCompleteBoxSample.xaml.cs' This should give you the start/code you're looking for.

In your case, you'll also need to create a cell template for the radgridview. Here's a quick sample of what that might look like:

<radControls:RadGridView x:Name="registerGridView" 
                             AutoGenerateColumns="False">  
        <radControls:RadGridView.Columns> 
            <radControls:GridViewToggleRowDetailsColumn /> 
            <radControls:GridViewDataColumn Header="Client" /> 
            <radControls:GridViewDataColumn Header="Site" />  
            <radControls:GridViewDataColumn Header="Name">  
                <radControls:GridViewDataColumn.CellTemplate> 
                    <DataTemplate> 
                        <StackPanel Orientation="Horizontal">  
                            <input:AutoCompleteBox HorizontalAlignment="Left" ItemsSource="{Binding Names}" SelectionChanged="OnSelectionChanged"/>
                        </StackPanel> 
                    </DataTemplate> 
                </radControls:GridViewDataColumn.CellTemplate> 
            </radControls:GridViewDataColumn> 
        </radControls:RadGridView.Columns> 
    </radControls:RadGridView> 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文