• 24.05.2025, 05:58
  • Registrieren
  • Anmelden
  • Sie sind nicht angemeldet.

 

Lieber Besucher, herzlich willkommen bei: Aqua Computer Forum. Falls dies Ihr erster Besuch auf dieser Seite ist, lesen Sie sich bitte die Hilfe durch. Dort wird Ihnen die Bedienung dieser Seite näher erläutert. Darüber hinaus sollten Sie sich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutzen Sie das Registrierungsformular, um sich zu registrieren oder informieren Sie sich ausführlich über den Registrierungsvorgang. Falls Sie sich bereits zu einem früheren Zeitpunkt registriert haben, können Sie sich hier anmelden.

Getting error "cannot locate resource"

Montag, 16. März 2015, 01:49

I'm trying to create my own custom control in Aquasuite. I'm getting this error when I check the code:

---------------------------
Test result
---------------------------
One or more errors in XAML code found!

'Initialization of 'System.Windows.Setter' threw an exception.' Line number '80' and line position '27'.

Cannot locate resource 'content/images/aqualis_fill_10.png'.

This makes no sense as the image is in the images folder. It can find other images but not the new ones I added. Here's the XAML:

<UserControl
x:Name="this"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" d:DesignHeight="50" d:DesignWidth="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<!--Simple databinding example-->
<!--1. Set up connection for this item (ie. temperature sensor)-->
<!--2. Bind values to your own usercontrol-->
<!--Binding example-->
<!--Content="{Binding ElementName=this, Path=DataContext.Value, FallbackValue=no data available}"-->

<!--default background-->
<Rectangle Grid.Row="0" Grid.RowSpan="1" Fill="#FF78949A" Opacity="1.0" />
<Rectangle Grid.Row="1" Grid.RowSpan="1" Fill="#FFF0F0F0" Opacity="1.0" />
<Rectangle Grid.Row="2" Grid.RowSpan="1" Fill="#FFF0F0F0" Opacity="1.0" />

<!--Content: binding to source value: -->
<!--Content: ElementName=this -->
<!--Content: Path=DataContext.Value, for connection to actual connected value -->
<Label
Content="{Binding ElementName=this, Path=DataContext.Value, FallbackValue=no data available}"
ContentStringFormat="Level: {0:F0} %"
Grid.Row="2"
Opacity="1.0"
Height="Auto"
Width="Auto"
Foreground="#FF000000"
FontSize="13"
FontFamily="Segoe UI"
FontWeight="Normal"
Margin="0,0,0,0"
Padding="0,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center" />

<!--Content: binding to source value: -->
<!--Content: ElementName=this -->
<!--Content: Path=DataContext.DataName, for connection to actual connected value name -->
<Label
Content="{Binding ElementName=this, Path=DataContext.DataName, FallbackValue=no data available}"
Grid.Row="0"
Opacity="1.0"
Height="Auto"
Width="Auto"
Foreground="#FFEEEEEE"
FontSize="11"
FontFamily="Segoe UI"
FontWeight="Normal"
Margin="3,0,0,0"
Padding="0,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center" />

<Image
Grid.Row="1"
Opacity="1.0"
Height="Auto"
Width="Auto"
Margin="5,5,5,5"
Stretch="Uniform"
StretchDirection="Both" >
<Image.Style>
<Style TargetType="{x:Type Image}">
<Setter Property="Source" Value="Content/images/aqualis_fill_20.png" />

<Style.Triggers>
<DataTrigger
Value="True"
Binding="{Binding ElementName=this, Path=DataContext.Value, ConverterParameter=7, Converter={StaticResource CompareSmalerConverter}}">
<Setter Property="Source" Value="Content/images/aqualis_fill_10.png" />
</DataTrigger>

<DataTrigger
Value="True"
Binding="{Binding ElementName=this, Path=DataContext.Value, ConverterParameter=17, Converter={StaticResource CompareSmalerConverter}}">
<Setter Property="Source" Value="Content/images/aqualis_fill_20.png" />
</DataTrigger>

<DataTrigger
Value="True"
Binding="{Binding ElementName=this, Path=DataContext.Value, ConverterParameter=27, Converter={StaticResource CompareSmalerConverter}}">
<Setter Property="Source" Value="Content/images/aqualis_fill_30.png" />
</DataTrigger>

<DataTrigger
Value="True"
Binding="{Binding ElementName=this, Path=DataContext.Value, ConverterParameter=37, Converter={StaticResource CompareSmalerConverter}}">
<Setter Property="Source" Value="Content/images/aqualis_fill_40.png" />
</DataTrigger>

<DataTrigger
Value="True"
Binding="{Binding ElementName=this, Path=DataContext.Value, ConverterParameter=47, Converter={StaticResource CompareSmalerConverter}}">
<Setter Property="Source" Value="Content/images/aqualis_fill_50.png" />
</DataTrigger>

<DataTrigger
Value="True"
Binding="{Binding ElementName=this, Path=DataContext.Value, ConverterParameter=57, Converter={StaticResource CompareSmalerConverter}}">
<Setter Property="Source" Value="Content/images/aqualis_fill_60.png"/>
</DataTrigger>

<DataTrigger
Value="True"
Binding="{Binding ElementName=this, Path=DataContext.Value, ConverterParameter=67, Converter={StaticResource CompareSmalerConverter}}">
<Setter Property="Source" Value="Content/images/aqualis_fill_70.png" />
</DataTrigger>

<DataTrigger
Value="True"
Binding="{Binding ElementName=this, Path=DataContext.Value, ConverterParameter=77, Converter={StaticResource CompareSmalerConverter}}">
<Setter Property="Source" Value="Content/images/aqualis_fill_80.png" />
</DataTrigger>

<DataTrigger
Value="True"
Binding="{Binding ElementName=this, Path=DataContext.Value, ConverterParameter=87, Converter={StaticResource CompareGreaterEqualConverter}}">
<Setter Property="Source" Value="Content/images/aqualis_fill_90.png" />
</DataTrigger>

<DataTrigger
Value="True"
Binding="{Binding ElementName=this, Path=DataContext.Value, ConverterParameter=97, Converter={StaticResource CompareGreaterEqualConverter}}">
<Setter Property="Source" Value="Content/images/aqualis_fill_100.png" />
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
</Grid>
</UserControl>


And the contents of the images folder:

Directory of D:\Program Files\aquasuite\Content\images

03/15/2015 09:27 AM <DIR> .
03/15/2015 09:27 AM <DIR> ..
11/02/2012 11:52 AM 2,278 alarm_0.png
11/02/2012 11:52 AM 3,177 alarm_1.png
11/02/2012 11:51 AM 3,179 alarm_2.png
11/06/2012 07:58 AM 7,234 aquaduct_0.png
11/06/2012 07:57 AM 6,628 aquaduct_100.png
11/06/2012 07:58 AM 6,654 aquaduct_50.png
11/12/2012 09:27 AM 4,603 aquaduct_eco_240.png
11/12/2012 09:26 AM 5,623 aquaduct_eco_360.png
03/12/2015 08:15 PM 2,777 aqualis_fill_10.png
03/12/2015 08:26 PM 2,437 aqualis_fill_100.png
03/12/2015 08:20 PM 2,628 aqualis_fill_20.png
03/12/2015 08:20 PM 2,612 aqualis_fill_30.png
03/12/2015 08:21 PM 2,589 aqualis_fill_40.png
03/12/2015 08:22 PM 2,571 aqualis_fill_50.png
03/12/2015 08:23 PM 2,549 aqualis_fill_60.png
03/12/2015 08:23 PM 2,531 aqualis_fill_70.png
03/12/2015 08:24 PM 2,498 aqualis_fill_80.png
03/12/2015 08:25 PM 2,475 aqualis_fill_90.png
10/30/2012 06:39 AM 3,472 auswertung.png
10/30/2012 06:37 AM 4,905 fans.png
03/12/2015 08:37 PM 2,149 flow-impeller.png
03/12/2015 08:36 PM 1,859 flow-shell.png
11/06/2012 04:48 AM 3,210 flow.png
11/06/2012 04:48 AM 6,154 pressure.png
03/12/2015 08:39 PM 3,261 pump-impeller.png
03/12/2015 08:39 PM 3,781 pump-shell.png
11/02/2012 12:29 PM 6,146 pump.png
10/30/2012 06:34 AM 3,997 regler.png
11/02/2012 10:44 AM 3,546 relais_an.png
11/02/2012 10:44 AM 2,931 relais_aus.png
11/06/2012 05:24 AM 1,747 running_fan_black.png
10/30/2012 06:35 AM 4,817 sensor.png
11/02/2012 10:50 AM 1,143 stecker.png
33 File(s) 118,161 bytes
2 Dir(s) 87,318,470,656 bytes free

What am I missing?

Montag, 16. März 2015, 07:40

Cannot locate resource 'content/images/aqualis_fill_10.png'.

This makes no sense as the image is in the images folder. It can find other images but not the new ones I added. Here's the XAML:
hi,
try out th path in this format:

Quellcode

1
Value="pack://siteoforigin:,,,/Content/images/aqualis_fill_10.png"

Montag, 16. März 2015, 16:22

Thanks! That solved the code check errors. That brings up a couple of follow up questions, plus there's new problem now.

1) Where/how did you find this syntax to use? I normally like finding and solving problems myself, so just wondering where you learned this syntax from.
2) Why is this syntax necessary for the images I added, but not for the factory installed images (aqualis_fill_20.png, aqualis_fill_50.png, aqualis_fill_100.png)?

Now it's displaying something, but it appears to be the wrong image. The reservoir is reading 48% right now, so I expected the control to show the aqualis_fill_50.png image. Instead it appears to be showing the aqualis_fill_80.png instead. Attached is updated XAML code plus a screen shot of what I am seeing on my screen as well as the two images so you can see the difference.

Thanks for your help!

P.S. Once I get this working properly I'll release it into the public domain.
»sircody01« hat folgende Bilder angehängt:
  • 2015-03-16_10-01-20.jpg
  • aqualis_fill_50.png
  • aqualis_fill_80.png
»sircody01« hat folgende Datei angehängt:

Mittwoch, 18. März 2015, 20:13

I found the problem. There's more than one comparator in the original sample. It uses both CompareSmalerConverter & CompareGreaterEqualConverter. It seems it should use only CompareGreaterEqualConverter instead. I'll posted the complete custom control in a new thread.