开发者

How do I edit a WPF DataTemplate in VS 2010 Design view?

开发者 https://www.devze.com 2023-03-04 08:19 出处:网络
How do I edit a WPF DataTemplate (or similar) in VS 2010 Design view? Is that even possible? I would love it if I could drag and drop template items (such as TextBlocks) around like I can with normal

How do I edit a WPF DataTemplate (or similar) in VS 2010 Design view?

Is that even possible? I would love it if I could drag and drop template items (such as TextBlocks) around like I can with normal (non-template) items. Doing so makes repositioning large numbers of elements much faster and easier than going line by line with cut/copy/paste methods.

For example, I would like to edit the following code in the Design view. However, the only control I can select is the ListView. In order to make any changes to the child-objects of ListView, I have to move the cursor to it or type it out. It's very limiting.

Example XAML:

<ListView ItemsSource="{Binding}"
          DataContext="{Binding}"
          d:DataContext="{d:DesignData Source=SampleData/PeopleSampleData.xaml}">
    <ListView.ItemsPanel>
        <ItemsPanelTemplate>
            <WrapPanel Orientation="Horizontal"/>开发者_如何学编程
        </ItemsPanelTemplate>
    </ListView.ItemsPanel>
    <ListView.ItemTemplate>
        <DataTemplate>
            <Border>
                <WrapPanel Orientation="Vertical">
                    <TextBlock Text="{Binding FirstName}"/>
                    <TextBlock Text="{Binding LastName}" />
                    <TextBlock Text="{Binding Age}"/>
                </WrapPanel>
            </Border>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

Note: You might say editing 3x TextBlocks isn't too bad, and I agree, but I've shortened the code substantially for example purposes.


I think Microsoft want to sell Blend too, so they will not incorporate this functionality into the VS designer.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号