How to create a DataTemplate using Expression Blend 3?

I am currently experimenting with Expression Blend 3 version MIX09 with the idea of using it mainly for a structured MVVM site with data binding, the ability to view live data during design . So far I have been very impressed and I must say that the Blend 3 generated XAML is not as bad as people say it. I got the following two examples: one with data binding and one with user controls (views) loaded dynamically. I can stay in Expression Blend 90% of the time while I develop my application, seeing the current data coming from my ViewModels as I design. I am switching to Visual Studio only, for example. creating configuration files or adding links is easier. improved intellisense Blend 3 allowed me to stay in Blend for most of my coding:

One thing that I am surprised that I cannot do in Expression Blend, however, after creating the ListBox, I would expect that I can right-click and create a DataTemplate . I can, of course, create a DataTemplate in the code, and then in the Resources / Window section I will find it again by clicking the button next to it to “enter the DataTemplate” and see the controls inside my “Objects” and “Timeline” panel "which is nice, but creating a DataTemplate from a control is so common, I think there is a way to do this that I'm just missing.

Where in Blend 3 you can “create a DataTemplate” for a ListBox or ListView, etc.

<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:TestDynamic456"
    mc:Ignorable="d"
    x:Class="TestDynamic456.CustomersView"
    x:Name="UserControl"
    d:DesignWidth="640" d:DesignHeight="480">

    <UserControl.Resources>
        <local:CustomersViewModel x:Key="CustomersDataProvider"/>
    </UserControl.Resources>
    <StackPanel x:Name="LayoutRoot" Background="{x:Null}">

        <ListBox ItemsSource="{Binding Path=GetAll, Source={StaticResource CustomersDataProvider}}"/>

    </StackPanel>
</UserControl>
+3
1

Blend 3 DataTemplate ItemsControl , Blend2;)

- > - > (ItemTemplate) → CreateEmpty

+3

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


All Articles