现在的位置: 首页 > 综合 > 正文

[zz]How to Create Sample Data in Blend 3

2013年11月24日 ⁄ 综合 ⁄ 共 2420字 ⁄ 字号 评论关闭

好文章大家分享--不作任何解释,转载


One of the cool new features of Blend 3 is the ability to generate random sample data. If you want to style a listbox or other control which normally requires some sort of data, you can set Blend to generate data so you can focus on the styling. 

Look for the Data tab (by default over on the right side). The button we are interested in represents a data source. Click it and select Define New Sample Data... There is also a button to add real data sources, but we won’t cover that in this tutorial.

This displays a dialog box asking where you would like to put the sample data source. For this tutorial select This document  which declares an instance of the SampleDataSource in the UserControl’s Resources element of the current page. You could choose Application which would place the sample data source in the App.xaml page instead, thus making it available for the entire application.

You can see below a SampleDataSource was created containing a Collection (a list of items) with each item having a property called Property1.

Click the + sign for  the collection to add additional properties. You can rename the properties if you like. You can also change the type of the random data the property will contain. You can select String, Number, Boolean or Image.

Now the cool part - you can click and drag the collection object in the SampleDataSource tree and drop it onto your Grid on the Artboard (the designer in the middle of the page). This will create a listbox that is bound to the collection you dragged.
Note: If you set a property to image, you must do this before dragging on to the Art Board. Otherwise your image will just be a reference.

Now you have a listbox with some sample data displayed. You can edit the template for the listbox items by selecting Edit Template from the Edit Generated Items context menu and changing  your listbox item layout how you please. 

Finally, if you would like to see your sample data when you press F5 to run your application, click the button next to the SampleDataSource (the button circled below) and select Enable When Testing Application. This will show your sample data when you run the application.

Now that you have styled your data you can pass your solution over to the developers, and they can integrate your UI back to the business layer and the real data. It’s also great for doing functional screen mockups. Makes for a much better mockup if it shows an example of the data as well!

About the Author

Stephen Price

Stephen Price is a Silverlight Developer with Design skills. (A Devigner?) He loves that Silverlight now brings the richness of desktop applications to the web. He runs the Perth Silverlight Designer and Developer Network user group (www.sddn.org.au).
He is also a cartoonist and caricaturist in his spare time and has a couple of blogs: www.littlevoices.com for his cartoons, and www.lythixdesigns.com for his coding posts.

抱歉!评论已关闭.