Thank you, I was struggling to figure out how to convert my Enum values to icons in my datagrid. With the help of this video I managed to write a IconConverter class that takes my enum value and converts it to a StreamGeometry instance. I can then pass this StreamGeometery instance along to my view to be used inside a element as the source for the Data attribute. Initially I wanted to use a Dynamic resource binding to bind StreamGeometery to a path but really couldn't figure out how make this work. PS: I'm using Avalonia instead of WPF, but it uses the same syntax so I didn't really need to change anything compared to your code :).
@@dotnetskoool5809 Thanks for the response. I got the problem resolved by removing *DateTime date = (DateTime)value;* so the *convert* code ended up like this: public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { DateTime date = DateTime.Today; return date.ToString("dd/MM/yyyy"); }
Really Helpful man. Finally found a simplest and easiest one on the internet. ❤️❤️
Wow. So simple thanks! Spent hours searching for this. Thanks alot!!
You are a superhero.
Very simple and easy to understand tutorial on ValueConverter. Really helped me understand the concept. Well done 👍
Thank you, I was struggling to figure out how to convert my Enum values to icons in my datagrid. With the help of this video I managed to write a IconConverter class that takes my enum value and converts it to a StreamGeometry instance. I can then pass this StreamGeometery instance along to my view to be used inside a element as the source for the Data attribute.
Initially I wanted to use a Dynamic resource binding to bind StreamGeometery to a path but really couldn't figure out how make this work.
PS: I'm using Avalonia instead of WPF, but it uses the same syntax so I didn't really need to change anything compared to your code :).
This was really helpul for me. Thanks a lot Dude
Why we used
DateTime date = (DateTime)value;
Value is always null. So it will always throw exception
Thanks it really helped. Lectures are useful for absolute beginners. :)
VERY GOOD VIDEO!!!!
very helpful lectures . can u please share code for lectures 20 to 28.
Thank you, it is helpful, if it is possible can you plese make video, how to hide fields which is available in view by using viewmodel class
When you are adding person to persons list every time. it is creating duplicate item.
It does not work!. Keep getting System.NullReferenceExeption error on *DateTime date = (DateTime)value;*
Followed your step to the letter.
I will upload my cod in Git Hub soon brother. Give me some time.
@@dotnetskoool5809 Thanks for the response. I got the problem resolved by removing *DateTime date = (DateTime)value;* so the *convert* code ended up like this:
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
DateTime date = DateTime.Today;
return date.ToString("dd/MM/yyyy");
}
@@quantomic1106 Although that might work, you're not actually converting anything. You're just returning a date, regardless of what the input is.
First line in the convert method should be removed for this to work .