Hi Fred,
Thanks for your help and providing a script to use IValueConverter. It works pretty well with fixing a typo:
$c = new MyNamespace.CutoffConverter
#replace with:
$c = new-object MyNamespace.CutoffConverter
my apologies if I was not clear in my question.. I am looking for an example to use it in an XAML GUI. so, along with your code, I have following XAML code to show a GUI and here is what I am looking to achive with IValueConverter:
If I enter a number in textbox that is say, less than cutoff (e.g. 50) then TextBox background should be red. Similarly, if the value is greater than 50 then it should set textbox background to Green.
Here is my XAML code.. I just don't know how to use converter in XAML
$xaml = @"
<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"
mc:Ignorable="d"
Title="Test IValueConverter" Height="143.58" Width="300">
<Grid>
<Label x:Name="lblHeader" Content="Enter a numeric value" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.479,0.457" Width="132"/>
<TextBox x:Name="txtTestValue" HorizontalAlignment="Left" Height="23" Margin="147,13,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="82"/>
</Grid>
</Window>
"@
TIA.