【问题标题】:cannot derive from sealed type 'ResourceDictionary',Xamarin.forms不能从密封类型“ResourceDictionary”、Xamarin.forms 派生
【发布时间】:2016-09-05 23:01:09
【问题描述】:

我想创建一个 Resourcedictionary,然后在另一个页面中使用(将调用 mergewith 以根据此页面将其添加到页面的 resourceDictionary。https://xamarinhelp.com/merged-dictionaries-xamarin-forms/)但我不断收到错误消息。 “Styledictionary”:不能从密封类型“ResourceDictionary”派生。

我正在使用 Xamarin 版本 4.1.2.18 我只是从跨平台添加了一个 xaml 页面。 my.xaml 看起来像

<ResourceDictionary xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="CrossPlatform.Styles.StylesDictionary">
  <Style x:Key="EnumButtonStyle" TargetType="Button">
    <Setter Property="BackGroundColor" Value="Green" />
    <Setter Property="TextColor" Value="Red" />
  </Style>

  </ResourceDictionary >

.xaml.cs 看起来像

namespace CrossPlatform.Styles
{
    public partial class StylesDictionary 
    {
        public StylesDictionary()
        {
            InitializeComponent();
        }
    }
}

【问题讨论】:

    标签: xamarin.forms resourcedictionary mergeddictionaries


    【解决方案1】:

    ResourceDictionary 在Xamarin.Forms 2.3.0.107 之后公开,因此您需要更新您的Xamarin.forms。您可以从 here 找到详细的变更集。

    【讨论】:

    • 嘿嘿,我其实用的是4.1.2.18版本
    • 嗨,我仔细看了看,你是对的。我没有 xamarin.forms 的最新 nuget 数据包。非常感谢
    猜你喜欢
    • 1970-01-01
    • 2015-01-26
    • 2013-08-31
    • 2016-08-19
    • 2018-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多