2013-04-18 4 views
0

Windows Phone 앱에서 XAML의 IValueConverter를 사용하고 있습니다. 나는 무엇을 놓치고변환기를 사용하는 'System.Exception'예외가 발생했습니다. XAML

public class SecondsToMinutesHour : IValueConverter 
{ 
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 
    { 
     int secs = int.Parse(value.ToString()); 
     TimeSpan ts = TimeSpan.FromSeconds(secs); 

     return String.Format("{0:D2}:{1:D2}:{2:D2}", 
         ts.Hours, 
         ts.Minutes, 
         ts.Seconds); 
    } 

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 
    { 
     throw new NotImplementedException(); 
    } 
} 

따를 때 내 코드 변환기

An exception of type 'System.Exception' occurred in System.Windows.ni.dll and wasn't handled before a managed/native boundary

점수는 형식 문자열이 오류를 제기하지만

<TextBlock Margin="0,0,10,0" 
      Text="{Binding Score, Converter={StaticResource SecondsToMinutesHour}}" 
      Foreground="{Binding DeviceID, Converter={StaticResource FontForegroundConverter}}" 
      FontWeight="{Binding DeviceID, Converter={StaticResource FontWeightConverter}}" 
      Grid.Column="3" /> 

내 변환 클래스는 무엇입니까?

답변

0

난 .. I는 Application.Resources 절의 SecondsToMinutesHour 컨버터의 참조를 포함해야 함을 알아 냈다

.... 
<Application.Resources> 
    <settings:AppSettings x:Key="AppSettings" /> 
    <app:SecondsToMinutesHour x:Key="SecondsToMinutesHour" /> 
....