Xaml Designer不显示用户控件的内容 [英] Xaml designer doesn't show content of a usercontrol
问题描述
我们在xaml中定义了一个专用的TabItem:
We have a specialized TabItem defined in xaml:
<TabItem x:Class="MyApp.MyViewTab" xmlns:my="clr-namespace:MyApp">
<my:MyView />
</TabItem>
和后面的代码:公共类MyViewTab:TabItem
。
而 MyView
是 UserControl
:
and code behind: public class MyViewTab : TabItem
.
And MyView
is a UserControl
:
MyView
在xaml设计器中正确显示,并且在运行时也正确显示为TabItem的内容。
MyView
is correctly shown in the xaml designer and also at run time correctly displayed as the content of the TabItem.
为什么xaml设计器不显示 MyView
的内容?这是一个灰色矩形,上半部为浅灰色,下半部为深灰色。
Why does the xaml designer not display the content of MyView
? It is a gray rectangle, top half light-gray, bottom half darker-gray.
推荐答案
请尝试在界面之间拆分屏幕设计器和代码,然后单击您声明 MyView
控件的代码行。这应该使设计者专注于 TabItem
的内容:
Try splitting the screen between the UI designer and the code and then clicking on the code line where you declared your MyView
control. This should focus the designer on the contents of that TabItem
:
<TabItem x:Class="MyApp.MyViewTab" xmlns:my="clr-namespace:MyApp">
<my:MyView /> <!--Click here-->
</TabItem>
如果单击 TabItem
中的任意位置,它应该做同样的事情。
If you click anywhere within the TabItem
, it should do the same.
这篇关于Xaml Designer不显示用户控件的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!