0
votes

MatérielDesignxamLtoolkit avec la bibliothèque de classe WPF?

Désolé pour la duplicate, mais ma faible réputation ne me permet pas de commenter des messages.

J'essaie d'utiliser MatièreDesignxamLToolkit avec WPF avec la bibliothèque de classe, exactement comme dans ce post: Comment inclure Matérieldesignxamltoolkit to WPF Class Bibliothèque?

-SO que j'ai installé Matériau Design Nuget and Ajout de matériel nommé matérielsDesign.xaml, où j'ai copié et coller ce code: xxx

alors j'ai créé une nouvelle page WPF où je Ressource supplémentaire, donc mon xaml ressemble à ceci: xxx

bien sûr, j'ai eu une erreur: la ressource {matérielsDesignbody, matérielsDesignpaper, matérielsDesignfont } n'a pas pu être résolu

comme @marija rakic mentionne dans le poteau, j'ai séché pour ajouter des lignes factices à ma classe Page1.xaml.cs Classe XXX

Mais cela n'a pas aidé. L'erreur était toujours là. J'ai donc essayé @trygve solution et a créé une classe supplémentaire nommée matièresDesign.xaml.cs où j'ai ajouté un assemblage xxx

et a ajouté une référence à MaterialDesign .xaml: xxx

mais il n'a pas non pas fonctionné et mentionné l'erreur est toujours là.Je ne sait pas où je fais une erreur ..


0 commentaires

3 Réponses :


0
votes

Voici comment je l'obtiens en cours d'exécution:

app.xaml strong> p> xxx pré>

mainwindow.xaml strong> strong>

<Window x:Class="PRWSolution.UI.View.Shell.MainWindow"
    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:local="clr-namespace:PRWSolution.UI.View"
    xmlns:language="clr-namespace:PRWSolution.UI.Properties.Langs"
    xmlns:setting="clr-namespace:PRWSolution.UI.Properties"
    mc:Ignorable="d"
    xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
    DataContext="{Binding Main, Source={StaticResource Locator}}"
    TextElement.Foreground="{DynamicResource MaterialDesignBody}"
    Background="{DynamicResource MaterialDesignPaper}"
    TextElement.FontWeight="Medium"
    TextElement.FontSize="14"
    WindowState="Maximized"
    WindowStyle="None"
    FontFamily="{materialDesign:MaterialDesignFont}"
    Title="MainWindow" 
    Height="800" 
    Width="1080">


1 commentaires

Le problème est que j'utilise une bibliothèque de classe qui ne contient pas app.xaml (définition d'application)



1
votes

Essayez de fusionner la ressource dictinaire avant que le balisage XAML soit analysé:

public partial class Page1 : Page
{
    public Page1()
    {
        Resources.MergedDictionaries.Add(new ResourceDictionary()
        { 
            Source = new Uri("pack://application:,,,/YourAssembly;component/MaterialDesign.xaml") 
        });
        InitializeComponent();
    }
}


0 commentaires

0
votes

Merci à @ mm8, je l'ai ajouté à la page.Resources dans XAML:

    <Page.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/pageTest;component/MaterialDesign.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Page.Resources>


0 commentaires