WP7 How to refresh separate Pivot Item?
In wp7 i want to refresh separate pivot Item? Is Possible this?
I 开发者_StackOverflowam create 5 pivot items Dynamically . I want to refresh Each item separate .
With WP7 there is no refresh or repaint concept. Silverlight uses retained-mode graphics, where the various UI elements are retained and managed.
When you want to 'refresh' your UI, you simple have to change the properties of your UI elements. The framework takes care of reflecting this change on the screen.
A good solution would be to data bind the content in each pivot item to a either separate view model (if you have many data items on that page) or controllable observable properties (list boxes)
Then you only have to refresh either the property or viewmodel independently, this is what is done with mode data pages on a pivot control for performance (and delaying loading of data to speed up display of the pivot control page)
Best thing to remember is that you are not refreshing the pivot page but the data displayed on it.
If you want to dynamically control how many pivot items there are then you will have to control that programatically.
I'm using next approach: every PivotItem is a separate UserControl, which is inherited from BaseUserControl. BaseUserControl has 2 abstract methods: OnPivotItemLoaded and OnSelected.
By default, PivotItems are empty (or they can be created in runtime, like in your case). Then, when Pivot's Item is loaded (just subscribe its event), i'm calling
private void PivotItemProfile_OnLoaded(object _sender, RoutedEventArgs _e)
{
SimpleLogger.WriteLine("Creating ProfileUserControl");
var pivotItem = _sender as PivotItem;
if (pivotItem == null) return;
if (pivotItem.Content == null)
pivotItem.Content = new ProfileUserControl();
var item = (pivotItem.Content as BaseUserControl);
if (item != null)
item.OnPivotItemLoaded();
}
Then, i'm also subscribed to Pivot's OnSelectionChanged event:
private void PivotControl_OnSelectionChanged(object _sender, SelectionChangedEventArgs _e)
{
var pivotItem = MainPivot.SelectedItem as PivotItem;
if (pivotItem == null) return;
var item = (pivotItem.Content as BaseUserControl);
if (item != null)
item.OnPivotItemSelected();
}
So, inside of PivotItem (UserControl) i can define, what i want to do at those events.
精彩评论