有没有办法在 WPF 中可视化 ItemTemplate

发布于 2024-09-29 22:53:38 字数 522 浏览 0 评论 0原文

我有一个 ItemsControl,它有一个相当复杂的 ItemTemplate,它允许用户编辑订单。不幸的是,Visual Studio 中的设计界面不显示 ItemTemplate,因此我无法获得所做更改的即时反馈。有没有办法在 Visual Studio 中可视化 ItemTemplate?这是我的控件的结构:

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

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

晨与橙与城 2024-10-06 22:53:38

过去,我只是将 DataTemplate 的内容复制到新的 WPFControl 中。有时我不得不使用一些虚拟数据才能正确查看它,但在大多数情况下它工作得很好。

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.

暖心男生 2024-10-06 22:53:38

如果您有复杂的 UI,最好将其重构为 UserControl,然后您可以在 Visual Studio 中正常可视化。

或者,我相信 Expression Blend(如果您有权访问它)允许您直接可视化 DataTemplate

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文