与 WPF 相比,Silverlight UserControl 继承有问题吗?

发布于 2024-10-19 20:51:50 字数 1911 浏览 0 评论 0原文

我已经成功创建了一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏雨凉 2024-10-26 20:51:50

在第 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文