Showing posts with label WPF. Show all posts
Showing posts with label WPF. Show all posts
Tuesday, January 1, 2013
Sunday, June 10, 2012
ValueConvertor & MultivalueConvertors in WPF with Example
Value convertor code and usage
usage
Multivalue convertor code and usage
usage
usage
Multivalue convertor code and usage
/// <summary>/// First one should be Result and the next value should be isWarning/// </summary>public class BoolToImageURLConverter : IMultiValueConverter{
{
{
{public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)string imagepath = string.Empty; if (values != null && values.Length == 2)bool? resultValue = values[0] as bool?;bool? isWarning = values[1] as bool?;if (resultValue.HasValue & isWarning.HasValue)//TODO:move the path to Resources// or try how to change style of the image to change the image itselfimagepath = (resultValue ==
imagepath =
}true ?"../Images/bullet_ball_glass_green.png" : "../Images/bullet_ball_glass_red.png");if (resultValue == true && isWarning == true)"../Images/bullet_ball_glass_yellow.png";else{
imagepath =
}
}"../Images/bullet_ball_glass_grey.png";else{
imagepath =
}
}
{
}
}"../Images/bullet_ball_glass_grey.png";return new System.Windows.Media.Imaging.BitmapImage(new Uri(imagepath,UriKind.Relative));public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)return null;
usage
<Window.Resources><!--ValueConvertors-->
</Window.Resources>
...
<Image Width="20" Height="20" ><Image.Source><MultiBinding Converter="{StaticResource BoolToImageURLConverter}"><!--ConverterParameter="parameter value" goes inside MultiBinding tag--><Binding Path="Result" /><Binding Path="IsWarning" /></MultiBinding></Image.Source></Image><cmn:BoolToImageURLConverter x:Key="BoolToImageURLConverter"/>
<Window.Resources><!--ValueConvertors--><cmn:BoolToImageURLConverter x:Key="BoolToImageURLConverter"/></Window.Resources> .......
<Image Source="{Binding Path=Result, Converter={StaticResource BoolToImageURLConverter}}" Width="20" Height="20" />
public class BoolToImageURLConverter : IValueConverter{
{
{public object Convert(object value, Type targetType,object parameter, CultureInfo culture)string imagepath;bool? boolValue = value as bool?;if (boolValue.HasValue)//TODO:move the path to Resources// or try how to change style of the image to change the image itselfimagepath = boolValue ==
}true ?"../Images/bullet_ball_glass_green.png" :"../Images/bullet_ball_glass_red.png";else{
imagepath =
}
}
{
}
}"../Images/bullet_ball_glass_grey.png";return imagepath;public object ConvertBack(object value, Type targetType,object parameter, CultureInfo culture)return null;
Monday, February 6, 2012
Subscribe to:
Posts (Atom)
Devops links
Build Versioning in Azure DevOps Pipelines
-
Build Versioning in Azure DevOps Pipelines
-
Ref 1: With using ajax cascading dropdown list http://csharpdotnetfreak.blogspot.com/2009/02/ajax-cascading-dropdownlist-database.html ...
-
SQL management addins VS Code Addins Javascript/ Typescript Prettier using powershell https://4sysops.com/archives/make-v...