2014-10-02 78 views
0
<Page x:Class="Myprog.StartPage" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:local="using:Myprog" 
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
mc:Ignorable="d"> 

<Page.Resources> 
    <DataTemplate x:Key="ItemTemplate2"> 
     <Border BorderThickness="1" Height="36" Width="598" Margin="0 -5" Padding="2" BorderBrush="#FFE2E2E2"> 
      <Grid Background="#eee" KeyDown="Grid_KeyDown_1"> 
       <Grid.Resources> 
        <local:strConverter x:Name="sameera1"/> 
       </Grid.Resources> 
       <TextBlock TextWrapping="Wrap" Text="{Binding ProductDesc,Converter={StaticResource sameera1}}" Margin="0,0,227,0" Foreground="Black" Padding="6,5,0,0"/> 
      </Grid> 
     </Border> 
    </DataTemplate> 
</Page.Resources> 

and then other elements... 

在我的代碼我已經定義的名字空間Myprog.StartPage類strConverter。 startPage是包含設計的頁面。定義Windows應用商店的應用程序資源XAML

我已經使用此資源strConverter來修改「ProductDesc」的值。

<Grid.Resources> 
    <local:strConverter x:Name="sameera1"/> 
</Grid.Resources> 
編譯下面的錯誤消息時得到顯示

..

「strConverter」這個名字並不在命名空間「使用:MYPROG」的存在。

我該如何解決?

+0

strConverter類的確切名稱空間定義是什麼? – eshaham 2014-10-02 07:02:09

+0

命名空間是Myprog – Sameera 2014-10-02 07:44:00

+0

等等,現在我看到了問題。寫一個答案。 – eshaham 2014-10-02 11:25:27

回答

0

當您想要消耗資源時,您需要爲該資源聲明​​一個密鑰。

所以,你應該解決您的資源聲明如下:

<Grid.Resources> 
    <local:strConverter x:Key="sameera1"/> 
</Grid.Resources> 

然後name屬性有一個資源字典裏面沒有任何意義。

相關問題