2012-11-26 21 views
1

我正在寫xaml和c#中的Windows 8商店應用程序,並使用the approach outlined in msdn本地化字符串。混合不顯示本地化的字符串

它在應用程序運行時正確顯示字符串,但在Expression Blend設計時它始終顯示一個空字符串。

<TextBlock x:Uid="IDST_LOAD_TITLE" x:Name="pageTitle" Text="" 
    Grid.Column="1" IsHitTestVisible="false" 
    Style="{StaticResource PageHeaderTextStyle}"/> 

我已經試過甚至擺脫文本=「」完全...

任何方式得到這個工作?

謝謝

+0

我目前面臨同樣的問題。有沒有其他的方法可以與Blend兼容? –

+0

在下面添加了答案 – swinefeaster

回答

0

我解決這樣說:

創建一個類,如:

public class Strang 
{ 
    public string   IDST_LOAD_TITLE 
    { get { return Strings.IDST_LOAD_TITLE; } } 

    public string   IDST_SAVE_TITLE 
    { get { return Strings.IDST_SAVE_TITLE; } } 
    ... 

它添加到您的App.xaml:

<Application 
    x:Class="MyApp.App" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:myApp="using:MyApp" 
    > 

    <Application.Resources> 
     <ResourceDictionary> 
      <ResourceDictionary.MergedDictionaries> 
       <ResourceDictionary Source="Common/StandardStyles.xaml"/> 
      </ResourceDictionary.MergedDictionaries> 

      <!-- Look here! --> 
      <myApp:Strang x:Key="Strang" /> 

     </ResourceDictionary> 
    </Application.Resources> 
</Application> 

,然後在你的頁面的xaml代碼中,執行如下操作:

 <TextBlock 
      x:Name="m_titleStatic" 
      Text="{Binding IDST_LOAD_TITLE}" 
      DataContext="{StaticResource Strang}" 
      />