Xaml designer doesn't show content of a usercontrol

人走茶凉 提交于 2019-12-11 16:14:21

问题


We have a specialized TabItem defined in xaml:

<TabItem  x:Class="MyApp.MyViewTab" xmlns:my="clr-namespace:MyApp">
    <my:MyView />
</TabItem>

and code behind: public class MyViewTab : TabItem. And MyView is a UserControl:

MyView is correctly shown in the xaml designer and also at run time correctly displayed as the content of the TabItem.

Why does the xaml designer not display the content of MyView? It is a gray rectangle, top half light-gray, bottom half darker-gray.


回答1:


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>

If you click anywhere within the TabItem, it should do the same.



来源:https://stackoverflow.com/questions/20422006/xaml-designer-doesnt-show-content-of-a-usercontrol

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!