与 WPF 相比,Silverlight UserControl 继承有问题吗?
我已经成功创建了一个 wpf 用户控件继承,如下所示:
<base:BaseUserControl x:Class="wpfcontrolinheritance.InheritedUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:base="clr-namespace:Base;assembly=Base"
mc:Ignorable="d"
d:DesignHeight="128" d:DesignWidth="238">
<Grid>
<Slider Height="23" HorizontalAlignment="Left" Margin="67,52,0,0" Name="slider1" VerticalAlignment="Top" Width="100" />
</Grid>
</base:BaseUserControl>
我尝试对 silverlight 执行相同的操作,但它不起作用。它说找不到 BaseSilverlight,而我确实将 BaseSilverlight 项目添加到了引用中。
<BaseSilverlight:BaseSilverlight x:Class="silverlightcontrolinheritance.inheritedusercontrol"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:base="clr-namespace:BaseSilverlight;assembly=BaseSilverlight"
mc:Ignorable="d"
d:DesignHeight="149" d:DesignWidth="318">
<Grid x:Name="LayoutRoot" Background="White">
</Grid>
</BaseSilverlight:BaseSilverlight>
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace BaseSilverlight
{
public class BaseSilverlight
{
}
}
没有人真正知道吗?我认为这是一个基本问题。
I have created successfully a wpf user control inheritance like this:
<base:BaseUserControl x:Class="wpfcontrolinheritance.InheritedUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:base="clr-namespace:Base;assembly=Base"
mc:Ignorable="d"
d:DesignHeight="128" d:DesignWidth="238">
<Grid>
<Slider Height="23" HorizontalAlignment="Left" Margin="67,52,0,0" Name="slider1" VerticalAlignment="Top" Width="100" />
</Grid>
</base:BaseUserControl>
I tried to do the same with silverlight but it doesn't work. It says BaseSilverlight cannot be found whereas I did add BaseSilverlight project to references.
<BaseSilverlight:BaseSilverlight x:Class="silverlightcontrolinheritance.inheritedusercontrol"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:base="clr-namespace:BaseSilverlight;assembly=BaseSilverlight"
mc:Ignorable="d"
d:DesignHeight="149" d:DesignWidth="318">
<Grid x:Name="LayoutRoot" Background="White">
</Grid>
</BaseSilverlight:BaseSilverlight>
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace BaseSilverlight
{
public class BaseSilverlight
{
}
}
Nobody really knows ? I thought this was a basic question.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在第 1 行中,您使用 BaseSilverlight:BaseSilverlight,但在下面几行中,您将命名空间标记为 xmlns:base="clr-namespace:BaseSilverlight; assembly=BaseSilverlight。
因此,第 1 行需要启动 base:BaseSilverlight
in line 1 you use BaseSilverlight:BaseSilverlight, but a few lines lower you decalre the namespace as xmlns:base="clr-namespace:BaseSilverlight;assembly=BaseSilverlight.
line1 therefore needs to start base:BaseSilverlight