c# - 在另一个列表视图的项目中单击事件后加载列表视图的数据
问题描述
我想在另一个列表视图的项目中单击事件后加载列表视图的数据例如,我有列表视图 A:ABC 并且在 A 中单击后将有 DEF,在 B 中单击将具有 GHI,C 将具有 JKL
问题是我必须从 Startup 事件加载它,所以它不会有 Null Reference Exception 事件。然后我加载了它,但它没有显示我想要的结果(仅来自启动事件的数据)。此外,我调试代码并弄清楚它有数据但启动时的数据不让它们显示。注意:另一个 ListView 显示在 Popup 上那么,我该如何解决这个问题?
解决方案
public ObservableCollection<int> Chars { get; set; }
private async void ClickItem(object sender, RoutedEventArgs e)
{
await Dispatcher.BeginInvoke((Action)delegate ()
{
for (int i = 1; i <= 3; i++)
{
Chars.Add(Chars.Count + 1);
}
}, DispatcherPriority.Input);
}
xml
<ListView ItemsSource="{Binding Chars}">
<ListView.ItemTemplate>
<DataTemplate>
<Button Content="{Binding }" Click="ClickItem"></Button>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
推荐阅读
- javascript - Javascript 承诺调用只发生一次
- ruby-on-rails - 从 rails 中的 graphql api 返回 base64 字符串
- r - 如何通过反应性在闪亮中添加递归模块
- c# - 如何使用 Selenium C# 在 Chrome 中禁用下载警告?
- javascript - Nextjs 上的 ContentEditable,更新未显示在状态
- c++ - 类无法访问其自己的私有静态 constexpr 方法 - Clang 错误?
- jquery - jsTree:AJAX 调用后刷新内容然后打开所有
- sql-server - 在 Oracle SQL 中重写 SQL-Server 中的触发器
- angular7 - 组件中的角度反应式表单组清除错误未从模板中清除
- mysql - sql数据库中的条件