UWP: Creating Goal Tracker App Part 5

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ธ.ค. 2024

ความคิดเห็น • 6

  • @pelopidas93
    @pelopidas93 8 ปีที่แล้ว

    Hello. Thank you for your videos. I want to ask you. How you did the DecimalIntConverter?

    • @javrabbit
      @javrabbit  8 ปีที่แล้ว

      Sorry about that. Here is the class for DecimalIntConverter
      public class DecimalIntConverter : IValueConverter
      {
      public object Convert(object value, Type targetType, object parameter, string language)
      {
      return Decimal.ToInt32((Decimal)value);
      }
      public object ConvertBack(object value, Type targetType, object parameter, string language)
      {
      throw new NotImplementedException();
      }
      }

    • @pelopidas93
      @pelopidas93 8 ปีที่แล้ว

      Is it better to check if it's really a decimal value? I mean something like this:
      if (value is decimal)
      return System.Convert.ToInt32(value);

    • @javrabbit
      @javrabbit  8 ปีที่แล้ว +1

      Good idea! It would be better to check the type before converting it. In this case the property that is being Binded is already type Decimal so i did not think to check before converting as this is only any tutorial. But it is a very good idea to check the type.

    • @pelopidas93
      @pelopidas93 8 ปีที่แล้ว

      Can I email you or something? I want to ask you something. If you want (and can) send me a message in my youtube account.

    • @javrabbit
      @javrabbit  8 ปีที่แล้ว

      Sorry about the delay. You can email me at RabbitApps@outlook.com