Hi George,
I have downloaded your sample solution and built it on my machine. I got a
compilation error indicating that the type of "CustomResources" doesn't
exist in the following xaml code:
<Expander Style="{DynamicResource {ComponentResourceKey
TypeInTargetAssembly={x:Type res:CustomResources},
ResourceId=CustomExpanderStyle1}}" >
I modify "CustomResources" to "TestExpander" and then pass the compilation.
I add the custom control in the Grid within the Window1. When I run the WPF
application, I find that the custom style isn't applied to the custom
control at all.
After doing some research, I find the reason of the problem is that the
custom control couldn't find the specified style at all. To solve this
problem, I make the following modifications and the custom control can find
the custom style now.
1. Modify the value of the Source property of the ResourceDictionary
element in the Generic.xaml:
<ResourceDictionary ...>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source = "Expander.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
2. Move the Generic.xaml and Expander.xaml files from the folder "Themes"
to the folder "Controls".
3. Merge the resources in the Generic.xaml into the resources of the
TestExpander:
<UserControl x:Class="CustomControls.Controls.TestExpander" ...>
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Generic.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
....
<Expander>
.....
</Expander>
<Expander>
....
<Expander>
....
</UserControl>
I will send the modified sample solution to your email box. Please run it
on your machine to see if there's any problem.
Sincerely,
Linda Liu
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.