Led data binding help

Gauge for WPF Forum

Posted 8 years ago by roie geron
Version: 16.1.0631
Avatar

Hi 

 

I am having difficulties to use Led Gauge and data binding 

I define the binding in the xaml file

<gauge:Led x:Name="Led1"LedState="{Binding Path=terminals[0].isTerminalConnected,Converter={StaticResource BooleanToLedStateConverter},Mode=OneWay}"

I declare BooleanToLedStateConverter in the resources 

<Window.Resources>

<gauge:BooleanToLedStateConverter x:Key="BooleanToLedStateConverter"/>
</Window.Resources>

 

but when running the program i get an exeption - "Cannot find resource named 'BooleanToLedStateConverter'. Resource names are case sensitive."

Is there an example how to use it ?

 

Regards

Roie 

Comments (6)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

Nothing stands out as being wrong in the example you gave, and we were able to try a working example with the Led bound to a CheckBox.IsChecked property.  My guess is that your Led isn't in the same XAML file as the converter resource, or something like that?  If you want to provide a simple XAML repro of this scenario, we can take a look at it.


Actipro Software Support

Posted 8 years ago by roie geron
Avatar

I created example application XAML file below

 

<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication1"
xmlns:gauge="http://schemas.actiprosoftware.com/winfx/xaml/gauge" xmlns:ribbon="http://schemas.actiprosoftware.com/winfx/xaml/ribbon" x:Class="WpfApplication1.MainWindow"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>

<gauge:Led HorizontalAlignment="Left" Height="100" Margin="391,136,0,0" VerticalAlignment="Top" Width="100" LedState="{Binding ledBox,Mode=OneWay,Converter={StaticResource BooleanToLedStateConverter}}"/>
<ribbon:CheckBox x:Name="ledBox" HorizontalAlignment="Left" Label="Led" Margin="57,150,0,0" VerticalAlignment="Top"/>

</Grid>
<Window.Resources>

<!-- Converters -->
<gauge:BooleanToLedStateConverter x:Key="BooleanToLedStateConverter" />

</Window.Resources>
</Window>

Answer - Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Roie,

It might be that you defined the Resources at the bottom of the file.  Try putting it at the top, before the Grid, and I bet it will work since StaticResource needs referenced resources defined above it.


Actipro Software Support

Posted 8 years ago by roie geron
Avatar

Hi 

 

Moving the resource to begining of the file helped !

Now the Led is blinking when the checkbox is checked and when it is not checked., I guess the default of the converter is to returen blinking for True and False ?

I have tried to chenge TrueState and FalseState but could not find a way to do it fron the xaml 

Do you have an example I can use ?

Answer - Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Roie,

You can define the converter like this in XAML:

<gauge:BooleanToLedStateConverter x:Key="BooleanToLedStateConverter" TrueState="On" FalseState="Off" />


Actipro Software Support

Posted 8 years ago by roie geron
Avatar

Hi 

Working well !

Thank you for the support 

Roie 

The latest build of this product (v24.1.2) was released 26 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.