在Silverlight中绑定到静态资源时出现语法错误

在Silverlight中绑定到静态资源时出现语法错误,silverlight,data-binding,Silverlight,Data Binding,从Silverlight应用程序中的UserControl访问应用程序资源时遇到问题。这是我的用户控件: <UserControl x:Class="MyApp.MainControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:basics="clr-

从Silverlight应用程序中的UserControl访问应用程序资源时遇到问题。这是我的用户控件:

<UserControl x:Class="MyApp.MainControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:basics="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" >
    <basics:TabControl TabStripPlacement="Left">
        <basics:TabItem Name="tabHome" Header="Home"></basics:TabItem>
        <basics:TabItem Name="tabPatients" Header="{StaticResource My_Patients}"></basics:TabItem>
        <basics:TabItem Name="tabOrganization" Header="My Organization"></basics:TabItem>
    </basics:TabControl>
</UserControl>

在将选项卡Patients选项卡的Header属性设置为静态资源My_Patients的行中出现错误

这是我的申请文件:

<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:System="clr-namespace:System;assembly=mscorlib" 
             x:Class="MyApp.App">
    <Application.Resources>
        <System:String x:Key="My_Patients">All My Patients</System:String>
    </Application.Resources>
</Application>

我所有的病人

有谁能告诉我出了什么问题吗?

据我回忆,这是一个已经存在了一段时间的错误——您可以为string属性指定string
StaticResource
,但不能为内容控件的内容(即
TabItem
标题

我可能错了,但我认为以下解决方法可能会有所帮助:

Header="{Binding Source={StaticResource My_Patients}}"

无论如何,如果您的目标是使应用程序可本地化,我建议您阅读。

看不出它有任何问题,在我的机器上运行良好。我无法重现这个问题,尽管仔细想想,我确实安装了SL4。这个问题在SL3中肯定仍然存在——我还没有在SL4中尝试过。