2012-12-28 63 views
2

首先,我正在使用Flipview構建一個Windows應用商店應用程序,並且我創建了一個類似於您可以在此博客上找到的第一個示例的自定義上下文指示器:http://blogs.u2u.be/diederik/post/2012/08/24/A-CXAML-FlipView-Context-Indicator-for-Windows-8.aspx 爲了保持簡短:我使用dependencyproperty進行綁定我的flipview到我的用戶控件。什麼是.NET 4.5 Windows Store應用程序等效於FrameworkPropertyMetadataOptions.AffectsRender?

我的問題:我用於我的上下文指示器的flipview被數據綁定到DefaultViewModel。由於我從Web API的flipview中獲取圖像,因此在加載頁面時,DefaultViewModel中的集合將爲null。在我成功加載了圖像後,我的DefaultViewModel [「collection」]被填充,flipview顯示相應的圖像。但是,我的上下文指示符保持不變,只有在頁面再次加載時纔會顯示正確的結果。

在我的用戶的DependencyProperty的是如下:

public static readonly DependencyProperty FlipviewProperty = 
     DependencyProperty.Register("Flipview", typeof(FlipView), typeof(FlipviewIndicator), new PropertyMetadata(null, FlipView_Changed)); 

    private static void FlipView_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e) 
    { 
     FlipviewIndicator indicator = d as FlipviewIndicator; 
     FlipView flipview = (e.NewValue as FlipView); 
     indicator.ItemsSource = flipview.ItemsSource; 
     Binding binding = new Binding(); 
     binding.Mode = BindingMode.TwoWay; 
     binding.Source = flipview; 
     binding.Path = new PropertyPath("SelectedItem"); 
     indicator.SetBinding(FlipviewIndicator.SelectedItemProperty, binding); 
    } 

我的問題:有沒有可能的方式,使我的DependencyProperty通知需要進行rerenderd我的用戶控件的用戶界面?我知道這是可能在WPF使用FrameworkPropertyMedata.AffectsRender這樣的:但是不再支持FrameworkPropertyMedata

public static readonly DependencyProperty FlipviewProperty = DependencyProperty.Register("Flipview",typeof(Flipview),typeof(FlipviewIndicator), new FrameworkPropertyMetadata(new Color(), FrameworkPropertyMetadataOptions.AffectsRender)); 

在Windows Store應用程序,有沒有在商店應用程序的相同呢?

在此先感謝!

+0

InvalidateArrange()呢? http://msdn.microsoft.com/en-us/library/system.windows.uielement.invalidatearrange.aspx – GenericTeaCup

回答

0

老問題 - 但簡短的回答是沒有。 Windows Store Xaml(如Windows 8.1)只有PropertyMetadata,但是在依賴項屬性的更改處理程序中,您仍然可以像在WPF中那樣,根據需要調用InvalidateMeasureInvalidateArrangeUpdateLayout之一。

相關問題