简体   繁体   中英

Passing Parameters from one XAML page to another

我有一个Tile Layout Control,其中包含Tiles,我用它来让用户浏览页面,我只是想在我的页面之间传递一些像字符串或整数这样的参数......怎么做?

you can try this approach or just by passing data between classes

http://msmvps.com/blogs/siva/archive/2007/05/11/storing-application-wide-data-the-wpf-way.aspx

 Application.Current.Properties["youvalueindex"];

Generally you will have some sort of manager controlling your windows. That manager would handle passing the data between the windows. The windows generally should not know anything about each other.

Simplistic Example

class Manager
{
   ...
   void DoSomething()
   {
      ViewModelA vma = new ViewModelA();
      WindowA wa = new WindowA();
      wa.DataContext = vma;
      wa.ShowDialog();
      ViewModelB vmb = new ViewModelB();
      vmb.SharedData = vma.SharedData;
      WindowB wb = new WindowB();
      wb.DataContext = vmb;
      wb.ShowDialog();
   }
   ...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM