我在Silverlight中很新,而且我的應用程序有一些問題。我將應用程序日期保留在數據庫和IsolatedStorage中。Silverlight刷新一個圖像取決於存儲在IsolatedStorage中的變量
我在用戶界面的頂部有一個圖像控件,用戶可以隨時看到應用程序的當前日期。我使用圖像,因爲我創建了一些時尚的圖像來以mm.yyyy格式表示日期。
我設置的炫魅Authentication_LoggedIn()的圖像控制的URI:
//setez luna curenta in isolatedStorage
adminUtilizContext.GetSetariParticulare(4, 0, (op) =>
{
foreach (var item in op.Value)
{
if (IsolatedStorageSettings.ApplicationSettings.Contains("lunaCurenta"))
IsolatedStorageSettings.ApplicationSettings["lunaCurenta"] = item.Substring(2);
else
IsolatedStorageSettings.ApplicationSettings.Add("lunaCurenta", item.Substring(2));
Uri uri;
uri = new Uri("/Indeco.SIEF;component/Images/Calendar/"+item.Substring(2)+".png", UriKind.RelativeOrAbsolute);
dataLuna.Source = new BitmapImage(uri);
}
}, null);
的XAML看起來是這樣的:
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
<Image Name="dataLuna" HorizontalAlignment="Right"/>
</StackPanel>
它工作正常,但問題出現在用戶更改時當前日期。在數據庫和IsolatedStorage中正確存儲。我正在更改圖片來源,但直到手動刷新頁面時纔會顯示新圖片。
您能告訴我如何自動執行此操作,而無需手動刷新頁面!
此致敬禮。
用戶更改日期的代碼位於相應用戶界面(CurrentConfigurations.xaml)的ViewModel(CurrentConfigurationViewModel.cs)中。有一個包含月份的組合框,SelectedItemChanged自動更新數據庫和IsolatedStorage.That是我已經把我在之前的評論中看到的代碼放在了一起。今年也有一個NumericUpDown控件,它們的工作原理是相同的。但是現在讓我們來談談本月,然後我會在這一年自己做:D! 再次感謝 正如你在這幅圖中看到的,當用戶登錄應用日期是2011年4月(右上),並且在我修改了月份之後,它顯示了舊日期,並且我在Db驗證了隔離存儲看起來沒問題。你可以看到我寫的代碼來更新Image源碼。
+1用於提供代碼/ XAML和良好的細節。 –