2013-06-24 70 views
0

我有這個自動生成FlipView的Windows商店應用 FlipView數據綁定到FlipView C#

<common:RichTextColumns x:Name="richTextColumns" Margin="117,0,117,47"> 
    <RichTextBlock x:Name="richTextBlock" Width="560" Style="{StaticResource ItemRichTextStyle}" IsTextSelectionEnabled="False"> 
     <Paragraph> 
      <Run FontSize="26.667" FontWeight="Light" Text="{Binding Title}"/> 
      <LineBreak/> 
      <LineBreak/> 
      <Run FontWeight="Normal" Text="{Binding Subtitle}"/> 
     </Paragraph> 
     <Paragraph LineStackingStrategy="MaxHeight"> 
      <InlineUIContainer> 
       <Image x:Name="image" MaxHeight="480" Margin="0,20,0,10" Stretch="Uniform" Source="{Binding Image}" AutomationProperties.Name="{Binding Title}"/> 
      </InlineUIContainer> 
     </Paragraph> 
     <Paragraph> 
      <Run FontWeight="SemiLight" Text="{Binding Content}"/> 
     </Paragraph> 
    </RichTextBlock> 

我需要這個類

public class InPageDesc 
{ 
    private string title; 
    private string subtitle; 
    private Image image; 
    private string content; 

    public string Title 
    { 
     get 
     { 
      return this.title; 
     } 
     set 
     { 
      this.title = value; 
     } 
    } 
    public string Subtitle 
    { 
     get 
     { 
      return this.subtitle; 
     } 
     set 
     { 
      this.subtitle = value; 
     } 
    } 
    public Image Image 
    { 
     get 
     { 
      return this.image; 
     } 
     set 
     { 
      this.image = value; 
     } 
    } 
    public string Content 
    { 
     get 
     { 
      return this.content; 
     } 
     set 
     { 
      this.content = value; 
     } 
    } 
} 

綁定,但它總是給我這個錯誤「價值不在預期的範圍內。「 我的代碼有什麼問題?

回答

1

在你的課InPageDesc - >不要將圖像存儲爲Image,但它的路徑爲string

例如public string Image =「Assets/Images/Image1.jpg」

這就是爲我設計的。