Note that there are some explanatory texts on larger screens.

plurals
  1. POResources not found when changing project location to another PC
    text
    copied!<p>I am quite new to WPF.When moving the wpf project form one PC to other i find that the resources are not found:</p> <pre><code>&lt;Window x:Class="BillingPad.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local ="clr-namespace:BillingPad" Title="MainWindow" Height="750" Width="810"&gt; &lt;Window.Resources&gt; &lt;Style TargetType="{x:Type Button}" x:Key="ButtonPref"&gt; &lt;Setter Property="FontSize" Value="48" /&gt; &lt;Setter Property="Background" Value="Green"/&gt; &lt;Setter Property="Foreground" Value="White" /&gt; &lt;/Style&gt; &lt;Style x:Key="myStyle" TargetType="Button"&gt; &lt;Setter Property="Background" Value="Orange" /&gt; &lt;Setter Property="FontStyle" Value="Italic" /&gt; &lt;Setter Property="Padding" Value="8,4" /&gt; &lt;Setter Property="Margin" Value="4" /&gt; &lt;/Style&gt; &lt;/Window.Resources&gt; ...... </code></pre> <p>From the code I am trying to get access to this resource using:</p> <pre><code> Button b = new Button(); b.Content = "Segundo bottón"; b.Style = (Style) (this.FindResource("ButtonPref")); </code></pre> <p>This throws the following exception:</p> <pre><code>&lt;ExceptionString &gt; System.Windows.ResourceReferenceKeyNotFoundException: Resource 'ButtonPref' not found </code></pre> <p>I do not know why it does not reach the resource as it is saved in MainWindow.xaml within scope... I am missing something or should change any in the configuration I am not aware of.</p> <p>Thanks</p>
 

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