Note that there are some explanatory texts on larger screens.

plurals
  1. POIs there any way to ignore application resources in contentpresenter
    text
    copied!<p>Some information related to problem: <a href="http://www.11011.net/archives/000692.html" rel="nofollow">http://www.11011.net/archives/000692.html</a></p> <p>Specific situation is : there is some generic textblock (key equals to type) styles declared in app.xaml which is in third party app, they used by all contentpresenters in my views ignoring my own styles.</p> <p>I've found few possible solutions:</p> <ol> <li><p>Explicitly assign all elements a style with overriden template &amp; add resource dictionary with my styles to contentpresenter resources.</p></li> <li><p>Add datatemplate for string, but there is a problem with access text detection ( may be solved by placing contentpresenter with ref to my own resources, isn't good solution because we increasing visual tree just to fix this problem)</p></li> </ol> <p>Probably any other solutions? </p> <p>P.S.: There is alot of views already exist, so first option is alot of work!</p> <p><strong>To reproduce create new wpf project and modify next files:</strong></p> <p><strong>App.xaml add generic style:</strong></p> <pre><code>&lt;Application.Resources&gt; &lt;Style TargetType="TextBlock"&gt; &lt;Setter Property="FontSize" Value="20"/&gt; &lt;/Style&gt; &lt;/Application.Resources&gt; </code></pre> <p><strong>MainWindow.xaml content is:</strong></p> <pre><code>&lt;Window.Resources&gt; &lt;ResourceDictionary&gt; &lt;ResourceDictionary.MergedDictionaries&gt; &lt;ResourceDictionary Source="Dictionary.xaml"/&gt; &lt;/ResourceDictionary.MergedDictionaries&gt; &lt;/ResourceDictionary&gt; &lt;/Window.Resources&gt; &lt;StackPanel&gt; &lt;Button Content="Hello world"&gt; &lt;Button.ContextMenu&gt; &lt;ContextMenu&gt; &lt;MenuItem Header="Access_Text"/&gt; &lt;MenuItem Header="NormalText"/&gt; &lt;/ContextMenu&gt; &lt;/Button.ContextMenu&gt; &lt;/Button&gt; &lt;TextBlock Text="WELCOME TO BLACK MESA"/&gt; &lt;/StackPanel&gt; </code></pre> <p><strong>Add Dictionary.xaml resource dictionary and add next style inside:</strong></p> <pre><code>&lt;Style TargetType="TextBlock"&gt; &lt;Setter Property="FontSize" Value="8"/&gt; &lt;/Style&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload