Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
O

Oscar Tsai

@Oscar Tsai
About
Posts
5
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • [Problem] Why can not Pass Image between 2 Views by using the same ViewModel (MVVM)
    O Oscar Tsai

    Thank for point me. Actually, I had solved this problem a few moment ago... XD Here is my solution: 1. Using singleton-pattern to fix one execution instance 2. At each View code-behind(???.xmal.cs) which needs to using the same ViewModel, I add below code

    this.context = viewmodel.instance

    BTW, I also ask in below Taiwan IT forum......and self-question at below to show my detail solution XD [問題] MVVM架構下,如何多個View共用同一個ViewModel變數 - iT 邦幫忙::一起幫忙解決難題,拯救 IT 人的一天[^] For you reference~~~ Thanks guys again :)

    WPF wpf help question database regex

  • [Problem] Why can not Pass Image between 2 Views by using the same ViewModel (MVVM)
    O Oscar Tsai

    In addition: ReviewView.xaml

    WPF wpf help question database regex

  • [Problem] Why can not Pass Image between 2 Views by using the same ViewModel (MVVM)
    O Oscar Tsai

    Here is something can't run properly. Is below code is written in NEW class called ReviewViewModel?

    public class ReviewViewModel : ViewModelBase
    {
    private DisplayViewModel _display = new DisplayViewModel();

    public DisplayViewModel
    {
        get { return \_display; }
        set { SetValue(ref \_display, value); }
    }
    

    }

    But the Intellisense will show warning about the declaration of DisplayViewModel and the function of SetValue is invalid.... What prerequisites are needed for this code? Sincere thank Richard Master to point me!! All Views need one ViewModel instance, and I had no idea about how to set one ViewModel instance until this post point me. And thank Gerry join this discussion.

    WPF wpf help question database regex

  • [Problem] Why can not Pass Image between 2 Views by using the same ViewModel (MVVM)
    O Oscar Tsai

    It uses String[].Any() to indicate the parameter. The problem is it can't display selected image file on DisplayView (page).... As my original post mention, all the same code can work well in one ViewModel and one View. When I separate the code to one ViewModel and 3 Views, it can not work as my expected. It just can show open dialog for selecting file, but display nothing after selection. I think the problem will be the operation on one View(DisplayControlView) can not effect another View(DisplayView)

    WPF wpf help question database regex

  • [Problem] Why can not Pass Image between 2 Views by using the same ViewModel (MVVM)
    O Oscar Tsai

    The purpose of this code is open image file in a page and display it in another page. I had tried set ViewModel by using Singleton Pattern, but it didn't work.... If I integrate to one View, it can display the image correctly. But I need to separate the views. I have no idea what's wrong in this MVVM code....and how to fix it? Please point me how can I do or let me know what keyword I can search the toturial/sample. Thank you all. -- The OpenFile button is on DisplayControlView and display on DisplayView. The View Schema is as below: MainWindow.xaml (window) | |__ReviewView.xaml (page)   |   |__DisplayControlView.xaml (page)   |   |__DisplayPanelView.xaml (page)     |     |__DisplayView.xaml (page) -- DisplayControlView.xaml

    ...
    ...

    -- DisplayView.xaml

    ...

    ...

    -- DisplayViewModel.cs

    class DisplayViewModel : ViewModelBase
    {
    private DisplayImageModel image { get; set; }

    private ObservableCollection imagelist = new ObservableCollection();
    public ObservableCollection ImageList
    {
    	get { return imagelist; }
    	set
    	{
    		imagelist = value;
    		OnPropertyChanged();
    	}
    }
    
    public string ImagePath
    {
    	get { return image.Path; }
    	set
    	{
    		if (image.Path != value)
    		{
    			image.Path = value;
    			OnPropertyChanged();
    		}
    	}
    }
    
    public DisplayViewModel()
    {
    	image = new DisplayImageModel();
    	ImagePath = @"C:\\Users\\oscartsai\\Desktop\\lenna.png";
    }
    
    public bool CanExecute()
    {
    	return true;
    }
    
    public RelayCommand OpenFile
    {
    	get { return new RelayCommand(openFile, CanExecute); }
    }
    
    private void openFile()
    {
    	string\[\] picExtName = new string\[\] { ".PNG", ".JPG", "JEPG", "BMP" };
    
    	OpenFileDialog dlgOpenFile = new OpenFileDialog() 
    	{ Filter = "Picture|\*.jpg;\*.jpeg;\*.bmp;\*.png|All File|\*.\*" };
    	if (dlgOpenFile.ShowDialog() != true)
    	{
    		return;
    	}
    	if (picExtName.Any(System.IO.Path.GetExtension(dlgO
    
    WPF wpf help question database regex
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups