UserControl-XAML in Namespace "packen"

  • WPF

Es gibt 6 Antworten in diesem Thema. Der letzte Beitrag () ist von mbfan.

    UserControl-XAML in Namespace "packen"

    Hallo,
    ich weiß nicht, ob ich hier möglicherweise komplett falsch bin, oder einfach WPF nicht verstehe - aber ich stelle meine Frage einfach ^^
    Also:
    Ich will meine Oberfläche in einem größerem Projekt in verschiedenen Namespacen organisieren. Im CodeBehind ist das ganze natürlich kein Problem

    VB.NET-Quellcode

    1. ​Namespace Frontend.Controls
    2. Public Class Applicant
    3. [...]
    4. End Class
    5. End Namespace

    Nun scheint aber damit die "Verbindung" zwischen XAML-Design und der CodeBehind-Datei verschwunden zu sein, da nichteinmal mehr "InitializeComponent()" gefunden wird.
    Wie sage ich der XAML-Datei jetzt, in welchem Namespace sie sich befinden soll?
    Bisherige Google-Suchen haben (zumindest für mich) nur die Möglichkeit erwähnt, andere Namespaces als "xmlns:xy" einzubinden - möglicherweise verstehe ich das aber auch falsch.
    Mein bisheriger Versuch war folgendes:

    XML-Quellcode

    1. ​<UserControl x:Class="Applicant"
    2. xmlns:local="clr-namespace:FPH.SpedV.ClientWPF.Frontend.Controls"
    3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    5. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    6. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    7. xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
    8. mc:Ignorable="d" >
    9. [...]
    10. </UserControl>

    Möglicherweise kann ja einer von euch mich auf den "rechten Pfad" zurückführen :)
    Nico aka mbfan
    You should live for that what you belive. - Drag-Drop Beschreibung
    probierma:

    XML-Quellcode

    1. <UserControl x:Class="fec:Applicant"
    2. xmlns:fec="clr-namespace:FPH.SpedV.ClientWPF.Frontend.Controls"
    3. xmlns:local="clr-namespace:FPH.SpedV.ClientWPF.Frontend.Controls"
    4. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    5. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    6. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    7. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    8. xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
    9. mc:Ignorable="d" >
    10. [...]
    11. </UserControl>
    edit: ach, du hast denselben xmlns bereits local genannt - aber ich glaub das ist kein guter xmlns-name, um damit gscheit was zu gliedern.
    xmlns sollten sehr kurz sein, und trotzdem ansatzweise was aussagen, etwa
    Viewmodel: vm
    System: sys
    Helpers: hlp
    UserInterface: ui

    etc.

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „ErfinderDesRades“ ()

    Hallo,
    in diesem Fall beschwert sich Visual Studio mit der Fehlermeldung "Die Zeichenfolge 'fec:' wurde an dieser Stelle nicht erwartet.".
    Nico
    You should live for that what you belive. - Drag-Drop Beschreibung
    also jetzt habich sowas:

    XML-Quellcode

    1. <Window x:Class="UUU.wndCachedPresenter"
    2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    4. xmlns:my="clr-namespace:CachedContentPresenterDemo"
    5. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    6. mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    7. Title="Select Person + use the vertical Splitter to modify the visual state of the Detail-View" Height="300" Width="800" DataContext="{Binding Mode=OneWay, Source={StaticResource Mainmodel}}"
    8. >
    9. <Grid>
    10. <Grid.RowDefinitions>
    und Codebehind

    VB.NET-Quellcode

    1. Namespace UUU
    2. Public Class wndCachedPresenter
    3. End Class
    4. End Namespace
    Hallo,
    das wirft zwar keine Fehler, ändert jedoch an der Situation nichts. Die Methoden InitializeComponent, FindResource sowie alle im XAML deklarierten Controls sind aus der Codebehind-Datei nicht zugreifbar.
    Nico
    You should live for that what you belive. - Drag-Drop Beschreibung
    Ja, bei mir jetzt auch - nachdem ich alle Controls aus dem Projekt ausgeschlossen und wieder hinzugefügt habe. Don't ask why ^^

    Danke jedoch für die tolle Hilfe - und ich hoffe dass da hier noch jemandem hilft ^^
    Nico
    You should live for that what you belive. - Drag-Drop Beschreibung