【发布时间】:2012-07-10 03:52:29
【问题描述】:
要动态加载的示例 XAML
<Grid xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
xmlns:usercontrols='clr-namespace:App.Views.UserControls'>
<TextBlock>Why don't you click the button?</TextBlock>
<usercontrols:SuperButton
Command="{Binding DataContext.OpenURLNew,RelativeSource=
{RelativeSource FindAncestor, AncestorType={x:Type ContentPresenter}}"
CommandParameter="50">
ClickMe</usercontrols:SuperButton>
</Grid>
尽管 SuperButton 是在同一个程序集中定义的,但加载失败并显示“无法加载未知类型的用户控件:超级按钮”。
我猜这是因为 SuperButton 有关联的代码隐藏?有没有办法帮助 XamlReader.Load() 找到它需要的东西?
【问题讨论】: