Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everybody,

I have made this in a resource dictionary istantiated in app.xaml:
XML
<Style TargetType="Button" x:Key="MainButton">
<Setter Property="FontSize" Value="18" />
<!--Other setters omitted-->


and in a page loaded in a frame inside a window (I put this code inside a Stackpanel.Resources and, inside the stackpanel, there are two buttons

XML
<Style BasedOn="{StaticResource MainButton}" TargetType="Button"/>


Chages in fontsize are visible only in the designer, but not when the application is running...

edit: I omitted that the page is inside a folder called Pages....

Does any of you know what is the problem with this implementation?

Thanks!

Jymmy097
Posted
Updated 18-Jun-14 21:45pm
v3
Comments
Irina Pykhova 16-Jun-14 13:32pm    
what about other setters? Can you get something else working, for example, Red background? And search all your xaml for FontSize, maybe you have conflicting setting elsewhere.

I think problem is with


1.You can use DynamicResource instead of StaticResource.
2.Double Quotes is missing so u can put double quotes at the end of Statement and can make

TargetType="Button"


3.After doing all above you can clean your solution.Rebuild your solution and can then try again.
 
Share this answer
 
v2
Comments
LLLLGGGG 16-Jun-14 13:46pm    
I am really sorry, but I haven't understood this code... Can you explain it better because br mode does not exists (or at least vs intellisense does not find it... Thanks!
LLLLGGGG 19-Jun-14 3:44am    
Thanks, but I cannot use dynamicresource in a based on statement according to the vs compiler..
ashok rathod 4-Jul-14 6:51am    
Can u please check as below


<Style BasedOn="{StaticResource MainButton}" TargetType="Button"/>
XML
I think problem is with

<Style BasedOn="{StaticResource MainButton}" TargetType="Button/>

should have

<Style BasedOn="{DynamicResource MainButton}" TargetType="Button"/>


because it might be the case that MainButton style is not available at runtime





You can also try cleaning the solution and Rebuilding it. it might also causes the problem.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900