将数据绑定到FlipView C#

本文关键字:FlipView 数据绑定 | 更新日期: 2023-09-27 18:19:51

我有这个自动生成的FlipView for Windows商店应用程序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>

我需要将它与这个类绑定

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;
        }
    }
}

但它总是给我这样的错误"值不在预期范围内。"我的代码出了什么问题?

将数据绑定到FlipView C#

在类InPageDesc->中,不要将图像存储为Image,而是将其路径存储为string

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

对我来说就是这样。