【问题标题】:Silverlight UserControl Inheritance is Buggy compared to WPF?与 WPF 相比,Silverlight UserControl 继承是否存在问题?
【发布时间】:2011-02-28 16:44:20
【问题描述】:

我已经成功创建了这样的 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
    {

    }
}

没有人真的知道吗?我认为这是一个基本问题。

【问题讨论】:

    标签: c# .net wpf silverlight xaml


    【解决方案1】:

    在第 1 行中,您使用 BaseSilverlight:BaseSilverlight,但在下面几行中,您将命名空间标记为 xmlns:base="clr-namespace:BaseSilverlight;assembly=BaseSilverlight。

    line1 因此需要启动 base:BaseSilverlight

    【讨论】:

      猜你喜欢
      • 2010-10-27
      • 1970-01-01
      • 1970-01-01
      • 2010-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多