当不存在项目时,自动完成框会弹出默认消息
我正在使用一个自动完成框,它绑定到代码隐藏中的列表。我想要的是,当列表中没有商品时,自动完成框应显示一条消息“不存在卖家”。
以下是 xaml 代码
<rm:AutoCompleteBox Name="sellerText" Grid.Column="0" Grid.Row="2" VerticalAlignment="Top" HorizontalAlignment="Left" Width="170" Margin="110,40,0,0" >
<rm:AutoCompleteBox.SelectedItem>
<Binding Source="{StaticResource insertTransaction}" Mode="TwoWay" UpdateSourceTrigger="Explicit" Path="Seller">
<Binding.ValidationRules>
<ExceptionValidationRule/>
</Binding.ValidationRules>
</Binding>
</rm:AutoCompleteBox.SelectedItem>
</rm:AutoCompleteBox>
隐藏代码
public NewRecord()
{
InitializeComponent();
List<string> ledgerList = new List<string>();
ledgerList = DAL_LedgerNameList.LoadLedgers();
sellerText.ItemsSource = ledgerList;
}
I am using an autocomplete box which is binded to a list in code-behind. What i want is that when there is no item in the list, the autocomplete box should show a message "no seller exist".
Following is the xaml-code
<rm:AutoCompleteBox Name="sellerText" Grid.Column="0" Grid.Row="2" VerticalAlignment="Top" HorizontalAlignment="Left" Width="170" Margin="110,40,0,0" >
<rm:AutoCompleteBox.SelectedItem>
<Binding Source="{StaticResource insertTransaction}" Mode="TwoWay" UpdateSourceTrigger="Explicit" Path="Seller">
<Binding.ValidationRules>
<ExceptionValidationRule/>
</Binding.ValidationRules>
</Binding>
</rm:AutoCompleteBox.SelectedItem>
</rm:AutoCompleteBox>
Code-behind
public NewRecord()
{
InitializeComponent();
List<string> ledgerList = new List<string>();
ledgerList = DAL_LedgerNameList.LoadLedgers();
sellerText.ItemsSource = ledgerList;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在后面的代码中添加此逻辑
You could just add this logic in your code behind