Hi all,
I am back again... :):( i am a lone tech person working in a team and have no one to help apart from you guys and Mr. Google. i am learning WPF now and created an application. it is working fine in view and code separated.
It extracts details from a web site. list out all the details of the product and their specifications and dump it all in an excel. so far all is good.
now i want to databind the view of giving the look and the progress to the user.
i am able to get the values out from the class and displaying in the lable. i want to show how much of each web is loaded by changing the color of the lable.
i want to show the state "Loading" "Interactive" ETC. to the user with change in color in the same lable.
i am able to get the string to the lable but the color change is not happening or triggering.
MY cut down XAML code:
start of XAML:(thought this might be important)
<Window x:Class="WebExtractor.AvnetMainClass"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Avenet_Web_Extractor.WebExtractor"
xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
Title="Avnet Product Details Extractor"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Height="300" Width="538"
ResizeMode="NoResize">
<Window.Resources>
<local:ColorConvert x:Key="colorConvert"/>
</Window.Resources>
part of the code where binding is happening
<StackPanel Margin="164,4,4,5" HorizontalAlignment="Stretch" >
<Label Name="lbl1PrdFll" BorderBrush="Black" BorderThickness="1" Width="312" Height="27" Margin="0,2,0,0" Background="{Binding RelativeSource={RelativeSource Self}, Path=Caption,Converter={StaticResource colorConvert}}" Content="{Binding Path=prdFrstState, UpdateSourceTrigger=PropertyChanged}" ></Label>
<Label Name="lbl2PrdFll" BorderBrush="Black" BorderThickness="1" Width="312" Height="27" Margin="0,2,0,0" Background="{Binding RelativeSource={RelativeSource Self}, Path=Caption,Converter={StaticResource colorConvert}}" Content="{Binding Path=prdScndState, UpdateSourceTrigger=PropertyChanged}"></Label>
<Label Name="lbl3PrdFll" BorderBrush="Black" BorderThickness="1" Width="312" Height="27" Margin="0,2,0,0" Background="{Binding RelativeSource={RelativeSource Self}, Path=Caption,Converter={StaticResource colorConvert}}" Content="{Binding Path=prdLstState, UpdateSourceTrigger=PropertyChanged}"></Label>
</StackPanel>
my vb.net code to convert the color
Namespace WebExtractor
<ValueConversion(GetType(String), GetType(SolidColorBrush))> _
Public Class ColorConvert
Implements IValueConverter
Public Function Convert(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IValueConverter.Convert
Dim boundWord As String = TryCast(value, String)
Dim returnBrush As SolidColorBrush = Nothing
Select Case boundWord.ToLower().Trim()
Case "UnInti"
returnBrush = New SolidColorBrush(Colors.Red)
Case "Loading"
returnBrush = New SolidColorBrush(Colors.Red)
Case "Loaded"
returnBrush = New SolidColorBrush(Colors.LightPink)
Case "Interactive"
returnBrush = New SolidColorBrush(Colors.Pink)
Case "Complete"
returnBrush = New SolidColorBrush(Colors.Green)
End Select
Return returnBrush
End Function
Public Function ConvertBack(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New Exception("Cant convert back")
End Function
End Class
End Namespace
can you please correct me