Time to create time in ListBox with data samples in WPF

I have a view (usercontrol) that contains a list. At run time, the list will be populated with instances of another view (also usercontrol). How can I populate a list at design time (in Blend and Cider) with samples that are themselves filled with data samples?

+4
source share
2 answers

Using VS2010, you can use Design-Time attributes (works for both SL and WPF). I usually have a data source layout, so this is just a question:

  • Adding a namespace declaration

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

  • Adding Layout Data Context to Window / Control Resources

     <UserControl.Resources> <ViewModels:MockXViewModel x:Key="DesignViewModel"/> </UserControl.Resources> 
  • Setting the development time data context

     <Grid d:DataContext="{Binding Source={StaticResource DesignViewModel}}"> ... 

It works well.

+5
source

You can find the BookLibrary WPF Application Framework (WAF) sample application interesting. It uses the new development time support for Visual Studio 2010 and Expression Blend 4. Download the WAF.Net4 version.

0
source

Source: https://habr.com/ru/post/1315036/


All Articles