WPF问题

编程入门 行业动态 更新时间:2024-10-27 01:25:09
本文介绍了WPF问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我以前已经做过,但是我找不到我的旧代码. 如何将窗口嵌入窗口中.假设我创建了Window1.xaml,我创建了一个自定义表单,并希望将其嵌入Window2.xaml中,而无需复制并粘贴xaml代码..TIA 我认为我的问题有些误导,我将其改写. 我有这个Window1.xaml,我添加了自定义标题和背景图像/颜色. 然后在Window2.xaml中,我希望Window1是自定义控件并将其嵌入此处. 不知道它的Content Presenters是否仍在搜索答案:)

i''ve done this before but i cannot find my old code. how do you embed a window inside a window. let say i created Window1.xaml i created a custom form, and want to embed it in Window2.xaml, without copy and pasting the xaml code.. TIA i think my question is somewhat misleading, i''ll rephrase it. i have this Window1.xaml i added custom headers and background images/colors. then in Window2.xaml, i want Window1 to be a custom control and embed it here. not sure if its Content Presenters, still googling for the answer :)

推荐答案

我认为只是将控件放入Window2的内容中即可. I think just putting the control inside the Content of Window2 should work.

基本上您需要的是: 1)创建一个空的UserControl. 2)打开以前的Window1.转到XAML源,然后选择顶级标签(文档节点)的所有内部XML. 3)转到新创建的UserControl的XAML源.将光标放在顶层元素内并粘贴. 4)您可能需要借用前一个Window1的顶级元素(文档元素)的某些属性.例如,您可能已经添加了额外的名称空间,以及其他一些文档级属性(例如背景色等),请复制与新创建的UserControl的顶级元素相关的内容. 5)编译,检查设计视图,解决小问题. Basically what you need is this: 1) Create empty UserControl. 2) Open your former Window1. Go to XAML source and select all inner XML of the top-level tag (document node). 3) Go to XAML source of newly created UserControl. Put a cursor inside a top-level element and paste. 4) You may need to borrow some attributes of the top-level element (document element) of the former Window1. For example, you could have added extra name spaces, and some other document-level attributes (such as background color, etc.) Copy what''s relevant to the top-level element of newly created UserControl. 5) Compile, check up designed view, fix minor problems.

更多推荐

WPF问题

本文发布于:2023-10-06 19:43:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1467636.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:WPF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!