您好我是WPF和绑定的新手,仍然试图获得它的悬念。目前我有一个Datagrid绑定到我的ObservableCollections,但现在我想将我的Autocompletebox绑定到Datagrids的列,但它没有正确绑定。如果我可以获得一些指导,如何从Datagrid显示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}
答案 0 :(得分:1)
试试这个
<telerik:RadAutoCompleteBox ItemsSource="{Binding Payments}" DisplayMemberPath="PaymentNo" TextSearchPath="PaymentNo"/>
密钥为TextSearchPath
,根据telerik docs将过滤“过滤控件中每个数据项时使用的属性的名称或路径。”