2013-02-15 31 views
9

Aşağıda ben NameSpace içinde TextColorConverter.cs yazmıştı Windows Phone StaticResource olarak ValueConverter Nasıl Kullanılır 8

benim App.xaml

<Application 
    x:Class="SpinrWindowsMobile.App" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" 
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" 
    > 

    <!--Application Resources--> 
    <Application.Resources > 
     <ResourceDictionary> 

      <local:LocalizedStrings xmlns:local="clr-namespace:SpinrWindowsMobile" x:Key="LocalizedStrings"/> 
      <converter:TextColorConverter xmlns:converter="clr-namespace:SpinrWindowsMobile.Common" x:Key="TextColorConverter"></converter:TextColorConverter> 

     </ResourceDictionary> 
    </Application.Resources> 

    .... 
</Application> 
olduğunu SpinrWindowsMobile.Common uygulamayı başlattık Bana istisna verirken , Tip SpinrWindowsMobile.Common.TextColorConverter Türü Örneği oluşturamaz. Nerede eksik olduğumu bilmiyorum. Aşağıda My Kalkınma Aracı Olarak Windows Phone için Microsoft Visual Studio 2012 kullanıyorum benim TextColorConverter.cs sınıf

class TextColorConverter : IValueConverter 
    { 
     public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 
     { 
      // some code 
     } 

     public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) 
     { 
      // some code 
     } 
    } 

olduğunu. Paylaşmak istediğim bir şey daha ValueConverstionAttribute Sınıfı'u System.Windows.Data ad alanı içinde alamıyorum. Herkes bana nerede yanlış olduğumu gösterir.

cevap

17

Sınıfınızı genel bir sınıf yapacaksınız (varsayılan olarak dahili olacaktır). Aksi takdirde örneklenemez.

kamu sınıf TextColorConverter: IValueConverter

+1

Teşekkür paul.You benim değerli çalışma saatleri kurtardı. –

İlgili konular