【问题标题】:Binding Autocompletebox to Datagrid Column将自动完成框绑定到 Datagrid 列
【发布时间】:2014-02-04 21:19:14
【问题描述】:

您好,我对 WPF 和绑定非常陌生,仍在尝试掌握它。目前我有一个 Datagrid 绑定到我的 ObservableCollections,但现在我想将我的 Autocompletebox 绑定到 Datagrids 的列,但它没有正确绑定。如果我可以获得一些关于如何将数据网格中的 PaymentNo 显示到 Autocompletebox 的指导,我将不胜感激。

认为这可能是唯一需要的代码

for (int iIndex = 1; iIndex <= totalpayments; ++iIndex)
        {
            PaymentInfo paymentInfo = new PaymentInfo();
            paymentInfo.PaymentNo = iIndex;
            paymentInfo.Date = date.AddMonths(iIndex);
            paymentInfo.Balance = Math.Round(CalculateBalance(iIndex), 2);
            paymentInfo.Payment = Math.Round(Payment, 2);   
            paymentInfo.Interest = Math.Round(CalculateInterestPart(iIndex), 2);
            paymentInfo.Principle = Math.Round(CalculatePrinciple(iIndex), 2);
            Payments.Add(paymentInfo);
        }

在 Xaml 方面

<DataGrid Grid.Row="1" ItemsSource="{Binding Payments}" Grid.RowSpan="2"/>
<telerik:RadAutoCompleteBox HorizontalAlignment="Left" Grid.Column="1" Grid.Row="6" VerticalAlignment="Top" ItemsSource="{Binding Payments.PaymentNo}"/>

我相信这与ItemsSource="{Binding Payments.PaymentNo}有关

【问题讨论】:

    标签: c# wpf xaml datagrid


    【解决方案1】:

    试试这个

    <telerik:RadAutoCompleteBox ItemsSource="{Binding Payments}" DisplayMemberPath="PaymentNo" TextSearchPath="PaymentNo"/>
    

    键是TextSearchPath,根据telerik docs将过滤“在过滤控件中的每个数据项时使用的属性的名称或路径。”

    【讨论】:

    • 谢谢老兄!寻求帮助
    猜你喜欢
    • 1970-01-01
    • 2011-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多