質問するログイン新規登録

質問編集履歴

2

意図的に内容を抹消する行為にあたるため

2021/09/13 11:39

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -1,3 +1,77 @@
1
+ ### 前提・実現したいこと
2
+ 環境: Win10 、VS2019、C#
3
+ フレームワーク:Prism、ReactiveProperty
4
+ 起動時に画像表示していた処理を
5
+ ボタンを押して画像表示させたいが
6
+ 表示できない。
7
+ MainWindowViewModel()内にある画像表示処理を
8
+ (画像表示は確認済)
9
+ ImageDispLayButtonExe()に移動すると、メッセージボックスは
10
+ 表示されますが画像が表示されません。
11
+ 任意のタイミングで画像を表示させたい場合は
12
+ どうすればよろしいでしょうか?
1
- まことすみませんが事情により削除することとなりました
13
+ 参考になるページ等、有りましたらアドバイスをお願いします。
2
-
14
+ 関連質問
15
+ https://teratail.com/questions/349170?nli=60ecfdf1-a4fc-4e75-94a8-4d000a040507
16
+ ### 該当のソースコード
17
+ ### MainWindow.xaml
18
+ ```
19
+ <Window x:Class="DrawCircle.Views.MainWindow"
20
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
21
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
22
+ xmlns:prism="http://prismlibrary.com/"
23
+ prism:ViewModelLocator.AutoWireViewModel="True"
24
+ Title="{Binding Title}" Height="400" Width="500"
25
+ WindowStartupLocation="CenterScreen">
26
+ <Grid>
27
+ <StackPanel>
28
+ <Button Content="画像表示" Command="{Binding ImageDispLayButton}" />
29
+ <Image Stretch="None" Source="{Binding Bitmap.Value}" Height="381" Width="496" />
30
+ <ContentControl prism:RegionManager.RegionName="ContentRegion" />
31
+ </StackPanel>
32
+ </Grid>
33
+ </Window>
34
+ ```
35
+ ### MainWindowViewModel.cs
36
+ ```
37
+ using Prism.Mvvm;
38
+ using System.Windows;
39
+ using Reactive.Bindings;
40
+ using System.Windows.Media.Imaging;
41
+ using System;
42
+ using Prism.Commands;
43
+ namespace DrawCircle.ViewModels
3
-
44
+ {
45
+ public class MainWindowViewModel : BindableBase
46
+ {
47
+ public ReactiveProperty<BitmapImage> Bitmap { set; get; }
48
+ public ReactiveProperty<BitmapImage> rp_image1 { set; get; }
49
+ public ReactiveCommand<string> changecommand { set; get; } = new ReactiveCommand<string>();
50
+ public MainWindowViewModel()
51
+ {
52
+ ImageDispLayButton = new DelegateCommand(
53
+ ImageDispLayButtonExe);
54
+ //画像表示
55
+ //BitmapImage image1 = new BitmapImage(new Uri(@"C:\Test\hoge.jpg"));
56
+ //rp_image1 = new ReactiveProperty<BitmapImage>(image1);
57
+ //Bitmap = rp_image1;
58
+ }
59
+ //コマンドのデリゲード定義
60
+ public DelegateCommand ImageDispLayButton { get; }
61
+ private void ImageDispLayButtonExe()
62
+ {
63
+ BitmapImage image1 = new BitmapImage(new Uri(@"C:\Test\hoge.jpg"));
64
+ rp_image1 = new ReactiveProperty<BitmapImage>(image1);
65
+ Bitmap = rp_image1;
66
+ MessageBox.Show("画像表示");
67
+ }
68
+ }
69
+ }
70
+ ```
71
+ ### 試したこと
72
+ ボタンを実行したときのimage1、rp_image1 、Bitmapの値を確認して画像への
73
+ パスが入ってるとこまでは確認しました。
74
+ ![イメージ説明](417a0c53366dce513cfe7a6aa3ee3eb1.jpeg)
75
+ ### 補足情報(FW/ツールのバージョンなど)
76
+ 環境: Win10 、VS2019、C#
77
+ フレームワーク:Prism、ReactiveProperty

1

都合により削除することとなりました。

2021/09/13 11:39

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -1,91 +1,3 @@
1
- ### 前提・実現したいこと
2
- 環境: Win10 、VS2019、C#
3
- フレームワーク:Prism、ReactiveProperty
1
+ まことにすみませんが事情により削除することとなりました
4
2
 
5
- 起動時に画像表示していた処理を
6
- ボタンを押して画像表示させたいが
7
- 表示できない。
8
-
9
- MainWindowViewModel()内にある画像表示処理を
10
- (画像表示は確認済)
11
- ImageDispLayButtonExe()に移動すると、メッセージボックスは
12
- 表示されますが画像が表示されません。
13
- 任意のタイミングで画像を表示させたい場合は
14
- どうすればよろしいでしょうか?
15
- 参考になるページ等、有りましたらアドバイスをお願いします。
16
-
17
- 関連質問
18
- https://teratail.com/questions/349170?nli=60ecfdf1-a4fc-4e75-94a8-4d000a040507
19
-
20
- ### 該当のソースコード
21
- ### MainWindow.xaml
22
- ```
23
- <Window x:Class="DrawCircle.Views.MainWindow"
24
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
25
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
26
- xmlns:prism="http://prismlibrary.com/"
27
- prism:ViewModelLocator.AutoWireViewModel="True"
28
- Title="{Binding Title}" Height="400" Width="500"
29
- WindowStartupLocation="CenterScreen">
30
- <Grid>
31
- <StackPanel>
32
- <Button Content="画像表示" Command="{Binding ImageDispLayButton}" />
33
-
34
- <Image Stretch="None" Source="{Binding Bitmap.Value}" Height="381" Width="496" />
35
-
36
- <ContentControl prism:RegionManager.RegionName="ContentRegion" />
37
- </StackPanel>
38
- </Grid>
39
- </Window>
40
- ```
41
- ### MainWindowViewModel.cs
42
- ```
43
- using Prism.Mvvm;
44
- using System.Windows;
45
- using Reactive.Bindings;
46
- using System.Windows.Media.Imaging;
47
- using System;
48
- using Prism.Commands;
49
-
50
- namespace DrawCircle.ViewModels
51
- {
3
+
52
- public class MainWindowViewModel : BindableBase
53
- {
54
- public ReactiveProperty<BitmapImage> Bitmap { set; get; }
55
- public ReactiveProperty<BitmapImage> rp_image1 { set; get; }
56
- public ReactiveCommand<string> changecommand { set; get; } = new ReactiveCommand<string>();
57
-
58
- public MainWindowViewModel()
59
- {
60
- ImageDispLayButton = new DelegateCommand(
61
- ImageDispLayButtonExe);
62
-
63
- //画像表示
64
- //BitmapImage image1 = new BitmapImage(new Uri(@"C:\Test\hoge.jpg"));
65
- //rp_image1 = new ReactiveProperty<BitmapImage>(image1);
66
- //Bitmap = rp_image1;
67
- }
68
-
69
- //コマンドのデリゲード定義
70
- public DelegateCommand ImageDispLayButton { get; }
71
-
72
- private void ImageDispLayButtonExe()
73
- {
74
- BitmapImage image1 = new BitmapImage(new Uri(@"C:\Test\hoge.jpg"));
75
- rp_image1 = new ReactiveProperty<BitmapImage>(image1);
76
- Bitmap = rp_image1;
77
-
78
- MessageBox.Show("画像表示");
79
- }
80
- }
81
- }
82
- ```
83
-
84
- ### 試したこと
85
- ボタンを実行したときのimage1、rp_image1 、Bitmapの値を確認して画像への
86
- パスが入ってるとこまでは確認しました。
87
- ![イメージ説明](417a0c53366dce513cfe7a6aa3ee3eb1.jpeg)
88
-
89
- ### 補足情報(FW/ツールのバージョンなど)
90
- 環境: Win10 、VS2019、C#
91
- フレームワーク:Prism、ReactiveProperty