如何在 Windows Phone 7 中检测到 UI 元素(全景图和列表框)的数据绑定何时完成?

发布于 2024-12-08 12:21:27 字数 1404 浏览 3 评论 0原文

我在全景中有一个全景控件和列表框控件。是否有任何我可以挂钩的“事件”或任何方式来检测与全景和/或列表框控件关联的所有数据绑定或 UI 显示何时完成?

我需要检测此事件的原因是因为我想仅在 Panorama 和/或 ListBox 控件完全绑定并完成渲染后才显示 ApplicationBar。

例如,我的 XAML 定义如下。

<controls:Panorama Name="panorama">
 <controls:Panorama.ItemTemplate>
  <DataTemplate>
   <ListBox ItemsSource="{Binding Details}">
    <ListBox.ItemTemplate>
     <DataTemplate>
      <TextBlock Text="{Binding Field1}"/>
      <TextBlock Text="{Binding Field2}"/>
      ...
      <TextBlock Text="{Binding FieldN}"/>
     </DataTemplate>
    </ListBox.ItemTemplate>
   </ListBox>
  </DataTemplate>
 </controls:Panorama.ItemTemplate>
</controls:Panorama>

我的普通 CLR 对象 (POCO) 如下所示。

public class MyPoco {
 List<Detail> Details { get; set; }
}
public class Detail {
 public string Field1 { get; set; }
 public string Field1 { get; set; }
 ...
 public string FieldN { get; set; }
}

在我的 C# 代码隐藏中,我按如下方式绑定数据。

List<MyPoco> pocos = GetMyPocosFromSomewhere();   
panorama.ItemsSource = myList;
ApplicationBar.IsVisible = true; //i only want to make this visible after the Panorama and ListBox controls have finished binding and rendering

现在,我上面概述的代码可以工作,但是在呈现全景/列表框控件之前,ApplicationBar 始终可见。对我来说,这让用户体验很尴尬。

任何帮助表示赞赏。

i have a Panorama control and ListBox controls inside the Panorama. is there any "event" that i can hook on to or any way to detect when all the data binding or UI display associated with the Panorama and/or ListBox controls are finished?

the reason i need to detect this event is because i want to show the ApplicationBar only after the Panorama and/or ListBox controls have completely binded and finished rendering.

for example, my XAML is defined as the following.

<controls:Panorama Name="panorama">
 <controls:Panorama.ItemTemplate>
  <DataTemplate>
   <ListBox ItemsSource="{Binding Details}">
    <ListBox.ItemTemplate>
     <DataTemplate>
      <TextBlock Text="{Binding Field1}"/>
      <TextBlock Text="{Binding Field2}"/>
      ...
      <TextBlock Text="{Binding FieldN}"/>
     </DataTemplate>
    </ListBox.ItemTemplate>
   </ListBox>
  </DataTemplate>
 </controls:Panorama.ItemTemplate>
</controls:Panorama>

my plain-old CLR object (POCO) looks like the following.

public class MyPoco {
 List<Detail> Details { get; set; }
}
public class Detail {
 public string Field1 { get; set; }
 public string Field1 { get; set; }
 ...
 public string FieldN { get; set; }
}

in my c# code-behind, i bind the data as follows.

List<MyPoco> pocos = GetMyPocosFromSomewhere();   
panorama.ItemsSource = myList;
ApplicationBar.IsVisible = true; //i only want to make this visible after the Panorama and ListBox controls have finished binding and rendering

right now, the code as i have sketched out above works, but the ApplicationBar is always visible before the Panorama/ListBox controls have rendered. to me, this makes the user experience awkward.

any help is appreciated.

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

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

发布评论

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

评论(1

め可乐爱微笑 2024-12-15 12:21:27

简短的回答是“不,你无法检测到它”。

但一个好的解决方案是将命令添加到 UI 工作队列中。调度员。像这样:

Dispatcher.BeginInvoke(() => ApplicationBar.IsVisible = true);

这样,当所有其他 UI 任务完成后,它会首先渲染它,并且体验不应该那么尴尬。

Short answer would be "no, you can't detect it".

But a good solution is to add the command to the UI work queue aka. the Dispatcher. Like this:

Dispatcher.BeginInvoke(() => ApplicationBar.IsVisible = true);

That way, it'll first render it, when all the other UI tasks are done, and the experience shouldn't be so awkward.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文