There are two dictionaries. They contain templates for CustomControl . For event handling, I connected x:Class="ModConstructor.Controls.ScriptComponent" and prescribed a script

 namespace ModConstructor.Controls { [ContentProperty("Content")] public partial class ScriptComponent : Control 

for my ScriptComponent
and x:Class="ModConstructor.Controls.PropertyField"

 namespace ModConstructor.Controls { public partial class PropertyField : Control 

for my PropertyField .
However, I still get the error. The Разделяемые объявления "App" не должны указывать различные базовые классы. What is wrong here? After all, before that, when they both referred to x:Class="ModConstructor.App" , he cursed that inside the App these two controllers create additional InitializeComponent()

PS When you double-click on an error, it opens App.xaml itself App.xaml red public partial class App : Application , but does not say anything specific.


UPD App.xaml

 <Application x:Class="ModConstructor.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Dictionaries/Basic.xaml"/> <ResourceDictionary Source="Dictionaries/ComboBox.xaml"/> <ResourceDictionary Source="Dictionaries/Converter.xaml"/> <ResourceDictionary Source="Dictionaries/Datatemplates.xaml"/> <ResourceDictionary Source="Dictionaries/List.xaml"/> <ResourceDictionary Source="Dictionaries/Palete.xaml"/> <ResourceDictionary Source="Dictionaries/ScrollBar.xaml"/> <ResourceDictionary Source="Dictionaries/Tabs.xaml"/> <ResourceDictionary Source="Dictionaries/Window.xaml"/> <ResourceDictionary Source="Dictionaries/XCTK.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> </Application> 

App.xaml.cs

 using System.Windows; namespace ModConstructor { /// <summary> /// Логика взаимодействия для App.xaml /// </summary> public partial class App : Application { } } 
  • I personally did not understand anything - Andrew NOP
  • I don't understand anything either. How does the CustomControl , described in the resource dictionary, add event handlers? The variant with mycontrol.Click += OnClick inside MainWindow does not offer. When everything was in App.xaml , I referred to the methods inside App.xaml.cs Now it is impossible. - Puro
  • one
    There is more a question - why? If all instances of the control must respond equally to a click, then why do you need some sort of explicit subscriber and so on? Put the logic inside the control code. - Andrey NOP
  • Well, I will have to write mybutton.Click += OnClick . I'm telling you. Earlier I could write Click="OnClick" in human markup and already in App.xaml.cs : private void OnClick(object sender, RoutedEventArgs e) {} . - Puro
  • Why in App.xaml.cs ? Do you have a file for your code? - Andrey NOP

0