【发布时间】:2009-05-07 09:15:27
【问题描述】:
我目前正在尝试使用Expression Blend 3 MIX09 version,其想法是主要将其用于具有数据绑定的 MVVM 结构化网站,能够在我设计时查看实时数据。到目前为止,我印象非常深刻,不得不说Blend 3 生成的XAML 并没有人们说的那么糟糕。我得到了以下两个示例,一个具有数据绑定,另一个具有动态加载的用户控件(视图)。当我设计我的应用程序时,我可以在 90% 的时间里停留在 Expression Blend,在我设计时看到来自我的 ViewModel 的实时数据。我切换到 Visual Studio 仅用于例如创建配置文件或添加引用更容易。 Blend 3 改进的智能感知使我在大部分编码中也能留在 Blend:
- MVVM base application that can be edited with Expression Blend and Visual Studio
- How to structure a WPF application with DataBinding so you can enhance it in Expression Blend
令我感到惊讶的是,我在 Expression Blend 中无法做到这一点,那就是在我创建了一个 ListBox 之后,我希望我可以右键单击并创建一个 DataTemplate。我当然可以在代码中创建一个 DataTemplate,然后在 Resources/Window 下我再次找到它,可以单击它旁边的按钮以“进入 DataTemplate”并在我的 Objects and Timeline 面板中查看控件,这很好.但是从控件创建 DataTemplate 是如此常见,我认为有一种方法可以做到这一点,我只是想念。
您可以在 Blend 3 的哪个位置为 ListBox 或 ListView 等“创建 DataTemplate”?
<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>
【问题讨论】:
标签: data-binding expression-blend