9
下面是我的App.xaml如何在Windows手機上使用ValueConverter作爲StaticResource的8
<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>
我在命名空間書面TextColorConverter.csSpinrWindowsMobile.Common 雖然啓動應用程序這讓我異常無法創建類型SpinrWindowsMobile.Common.TextColorConverter的實例。我不知道我錯在哪裏。 下面是我的TextColorConverter.cs類
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
}
}
我使用Microsoft Visual Studio 2012對於Windows Phone作爲我的開發工具。 我想分享的另一件事我沒有得到ValueConverstionAttribute類在System.Windows.Data命名空間。 任何人都可以指導我,我錯在哪裏。
感謝paul.You救了我寶貴的工作時間。 – 2013-02-18 07:29:54