I have one file GraphView.XAML. I have split the Resources section into two ResourceDictionary files (Vertices.xaml and Edges.xaml) which I merge as follows:
GraphView.XAML
<Window x:Class="graph_app.GraphView" ... >
<Grid>
<Grid.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Design/Vertices.xaml"/>
<ResourceDictionary Source="Design/Edges.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Grid.Resources>
...
<\Grid>
If not split the code works, but if split I get an error in the Vertices.xaml, telling me that the method ChangeVertexColor_OnClick cannot be resolved:
Vertices.XAML
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:graph_app">
<Style TargetType="{x:Type controls:VertexControl}">
<EventSetter Event="MouseDoubleClick" Handler="ChangeVertexColor_OnClick"/>
^^^cannot resolve symbol^^^^
</Style>
</ResourceDictionary>
I repeat, if put in one single XAML the code works. Moreover, the ChangeVertexColor_OnClick method is implemented in GrapView.xaml.cs so it should be recognized, but somehow after the split the Vertices.xaml is losing track of the x:Class (I suppose it ignores its existence since it's a separated file).
How can I access ChangeVertexColor_OnClick from the separated ResourcesDictionary file?
Thanks
Nothing strange is happening here :) - it just shouldn't work, because this is the way it's designed. I can see 2 possible solutions:
ChangeVertexColor_OnClick
method there read more herecontrols:VertexControl
(so kind of, revert your split change)