How can I get DesignTime data in WinRT XAML so the designer shows sample data?
相关问题
- Listview applies a check to other listview items h
- how to disable caching HTTP GET in metro app, I am
- ListView in a metro app does not get its vertical
- cant use store test kit while Working with SQLite
- Windows 8 app (html & Javascript) : alternate way
相关文章
- New Windows Application - What language?
- libxml2 missing for nokogiri gem on Windows 8 x64
- Building Windows 8 Metro App on Windows 7 with Vis
- Windows 8 & MySQL? What are my options?
- Visual Studio 2012 designer error
- Prevent the listview from scrolling to its top pos
- How to get the text of textbox to textblock in ano
- XAML grouped GridView/Semantic Zoom not displaying
Here is the d:DesignInstance sample:
I will also use Jerry's Fruit class, but I won't use MVVM here as you don't need that to make it works.
Basically, we need to create the data model class (e.g., ViewModel or Model) that we want to have design data (e.g., in this case, I create a child class, but you don't need to).
Then in our XAML, we can use d:DataContext to bind the child class.
Please note this line:
Now you should see your design time data on both Visual Studio Designer and Blend.
P.S. In Blend 2013, there is a data tab that let you create sample data as well.
Simple enough.
Create a Model like this:
Create a base ViewModel like this:
Create a real ViewModel like this:
Create a fake-data ViewModel like this:
Do this in your XAML:
Have fun!
PS: you can also attempt to use d:DesignData. That approach also works. I feel it is not as straight forward. In the end, it's up to you how to do it. Either way, don't miss out on DeisgnTime data!