180 likes | 294 Vues
This guide shares seven useful tips for building efficient user interfaces in your applications. Learn about customizing context menus, managing item styles, utilizing panorama selectors, and implementing live tiles. It also covers best practices for managing state in your view models, including how to register and unregister messengers effectively. Additionally, understand the importance of clearing properties and avoiding user input conflicts. Improve your UI development skills with these actionable insights and practical examples.
E N D
Account Helper 经验分享 @徐水峰(Alexis )
Agenda ProgressIndicator 7 useful tips
1. Custom ContextMenu <toolkit:ContextMenuService.ContextMenu> <toolkit:ContextMenuIsZoomEnabled="False" Background="White"> <toolkit:MenuItem Command=“…"> <toolkit:MenuItem.Header> <StackPanel Orientation="Horizontal"> <Image Source="Images/Appbar/edit.png" /> <TextBlock Text="编辑"Foreground="Black"/> </StackPanel> </toolkit:MenuItem.Header> </toolkit:MenuItem> ……………. </toolkit:ContextMenu> </toolkit:ContextMenuService.ContextMenu>
2. ItemContainerStyle Gets or sets the Style that is applied to the container element generated for each item. <Style x:Key="S_ListBoxItem"TargetType="ListBoxItem"> <SetterProperty="HorizontalContentAlignment" Value="Stretch" /> </Style>
5. Unregister Messenger in time Method 1 Register messengers in Page OnNavigatedTometod Unregister in Page OnNavigatedFrommethod Method 2 Register messengers in Page Constructor method Unregister in Page OnBackKeyPressmethod
6. Clear VM Property in time Why should we do that ? Consider following situation: MainPageDetailPage: ADetailVM.ImgSource Press BackKeygo back and select another item MainPageDetailPage: BDetailVM.ImgSource A Temp page or detail page ,we should remember: Clear Property in Time
7. Avoid user input conflicts Consider that: how can we enable items in list can receive both Tap and Touch and Hold ?
Source Code http://accounthelper.codeplex.com
How to use ProgressIndicator In MainPage.xaml.cs 1.ProgressIndicator pi = newProgressIndicator(); 2. pi.Text = "Hello World"; pi.IsIndeterminate = true; pi.IsVisible = true; 3. SetValue(SystemTray.IsVisibleProperty, true); SetValue(SystemTray.ProgressIndicatorProperty, pi);
Have a Test 需求: 开启广告按钮后,每隔2秒自动播放一条广告