Settings.settings
ユーザーが画像を選択して保存すると、すべてのボタン、ナビゲーションバーの項目などに適用される WPF アプリケーションを作成しました。ファイルに画像パスを保存するコードを書きました。画像を選択すると、これがデータベースに保存されますがnavigation bar items or buttons source of image
、アプリケーションを再起動するまで適用されません。ここに私のコードは次のとおりです。
public partial class MainWindow : DXWindow
{
public MainWindow()
{
InitializeComponent();
Refreshicon();
}
public void Refreshicon()
{
BitmapImage bi = new BitmapImage(new Uri(ApplicationSettings.Default.ImageName)); //Image From Settings File!
MessageBox.Show("Image Path" + bi.ToString());
navBarGroup1.ImageSource = bi;
navBarGroup2.ImageSource = bi;
navBarItem1.ImageSource = bi;
navBarItem2.ImageSource = bi;
}
アプリケーションを再起動せずにユーザー定義のイメージ パスを適用するにはどうすればよいnavigation bar items or buttons
ですか?
編集
//以下のコードは、画像を保存してRefreshicon()
関数を呼び出すためのものです
private void Button_Click_SaveImage(object sender, RoutedEventArgs e)
{
string imagepath = ApplicationSettings.Default.ImageName;
ApplicationSettings.Default.SetImage(imageEdit1.ImagePath);
MainWindow a = null;
if (a == null)
{
a=new MainWindow();
a.Refreshicon();
}
}