[英]Binding data to FlipView C#
I have this auto generated FlipView for Windows store app FlipView 我有这个自动生成的Windows应用商店FlipView FlipView
<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>
I need to bind it with this class 我需要将其与本课程绑定
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;
}
}
}
But it always gave me this error "Value does not fall within the expected range." 但是它总是给我这个错误“值不在预期范围内”。 What is wrong with my code? 我的代码有什么问题?
In your class InPageDesc
-> do not store the image as an Image
, but the path to it as a string
. 在您的类InPageDesc
>中,不要将图像存储为Image
,而是将其路径存储为string
。
eg public string Image = "Assets/Images/Image1.jpg" 例如,公共字符串Image =“ Assets / Images / Image1.jpg”
That's what works out for me. 那就是对我有用的东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.