Question

Led data binding help

Posted 3 years ago by Avatar roie geron

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 3 years ago by Actipro Software Support - Cleveland, OH, USA

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 3 years ago by roie geron

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>

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

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 3 years ago by roie geron

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 ?

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

Hi Roie,

You can define the converter like this in XAML:

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

Actipro Software Support
Posted 3 years ago by roie geron

Hi 

Working well !

Thank you for the support 

Roie 

Information The latest build of this product (2018.1 build 0673) was released 1 month ago, which was after the last post in this thread.

Add a Comment

Please log in to a validated account to post comments.