Naresh
Naresh

Reputation: 25753

Is there a way to visualize an ItemTemplate in WPF

I have an ItemsControl that has a fairly complex ItemTemplate which allows the user to edit an Order. Unfortunately the design surface in Visual Studio does not show the ItemTemplate so I don't get an instant feedback of the changes I make. Is there a way to visualize the ItemTemplate in Visual Studio? Here's the structure of my control:

<ItemsControl ItemsSource="{Binding Orders, Mode=TwoWay}">
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <Grid>
                <!-- Fairly complex form here -->
            </Grid>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

Upvotes: 4

Views: 565

Answers (2)

Steve Greatrex
Steve Greatrex

Reputation: 15999

If you have complicated UI, it might be better to refactor it out into a UserControl, which you can then visualise normally in Visual Studio.

Alternatively, I believe that Expression Blend (if you have access to that) allows you to visualise the DataTemplate directly

Upvotes: 2

Rachel
Rachel

Reputation: 132548

In the past I've just copied the contents of the DataTemplate into a new WPFControl. Sometimes I've had to use some dummy data to view it properly, but for the most part it works fine.

Upvotes: 3

Related Questions