Windows 8 商店应用程序 : Using multiple RichTextColumns in a flipview control

标签 windows xaml windows-8 windows-store-apps

我试图在翻转 View 中以两种语言(并排)显示两列富文本。如何在 RichTextColumns 中创建两列并将它们绑定(bind)到两个不同的数据源?

翻转 View 控件如下所示:

`翻转 View x:名称=“翻转 View ” AutomationProperties.AutomationId="ItemsFlipView" AutomationProperties.Name="项目详细信息" TabIndex="1" Grid.RowSpan="2" ItemsSource="{Binding Source={StaticResource itemsViewSource}}">

        <FlipView.ItemContainerStyle>
            <Style TargetType="FlipViewItem">
                <Setter Property="Margin" Value="0,137,0,0"/>
            </Style>
        </FlipView.ItemContainerStyle>

        <FlipView.ItemTemplate>
            <DataTemplate>

                <!--
                    UserControl chosen as the templated item because it supports visual state management
                    Loaded/unloaded events explicitly subscribe to view state updates from the page
                -->
                <UserControl Loaded="StartLayoutUpdates" Unloaded="StopLayoutUpdates">
                    <ScrollViewer x:Name="scrollViewer" Style="{StaticResource HorizontalScrollViewerStyle}" Grid.Row="1">
                        <Grid>

                        <!-- Content is allowed to flow across as many columns as needed -->
                        <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="ምዕራፍ "/>
                                    <Run FontSize="26.667" FontWeight="Light" Text="{Binding ChapterNumber }"/>
                                    <LineBreak/>

                                    <!--<Run FontWeight="Normal" Text="{Binding Subtitle}"/>-->
                                </Paragraph>

                                <Paragraph>
                                    <Run FontWeight="SemiLight" Text="{Binding ChapterContent}"/>
                                </Paragraph>

                            </RichTextBlock>

                            <!-- Additional columns are created from this template -->
                            <common:RichTextColumns.ColumnTemplate>
                                <DataTemplate>
                                    <RichTextBlockOverflow Width="560" Margin="80,0,0,0">
                                        <RichTextBlockOverflow.RenderTransform>
                                            <TranslateTransform X="-1" Y="4"/>
                                        </RichTextBlockOverflow.RenderTransform>
                                    </RichTextBlockOverflow>
                                </DataTemplate>
                            </common:RichTextColumns.ColumnTemplate>
                        </common:RichTextColumns>

                        <VisualStateManager.VisualStateGroups>

                            <!-- Visual states reflect the application's view state inside the FlipView -->
                            <VisualStateGroup x:Name="ApplicationViewStates">
                                <VisualState x:Name="FullScreenLandscape"/>
                                <VisualState x:Name="Filled"/>

                                <!-- Respect the narrower 100-pixel margin convention for portrait -->
                                <VisualState x:Name="FullScreenPortrait">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="richTextColumns" Storyboard.TargetProperty="Margin">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="97,0,87,57"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="image" Storyboard.TargetProperty="MaxHeight">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="400"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>

                                <!-- When snapped, the content is reformatted and scrolls vertically -->
                                <VisualState x:Name="Snapped">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="richTextColumns" Storyboard.TargetProperty="Margin">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="17,0,17,57"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="scrollViewer" Storyboard.TargetProperty="Style">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource VerticalScrollViewerStyle}"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="richTextBlock" Storyboard.TargetProperty="Width">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="280"/>
                                        </ObjectAnimationUsingKeyFrames>
                                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="image" Storyboard.TargetProperty="MaxHeight">
                                            <DiscreteObjectKeyFrame KeyTime="0" Value="160"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        </Grid>
                    </ScrollViewer>
                </UserControl>
            </DataTemplate>
        </FlipView.ItemTemplate>
    </FlipView>`

最佳答案

如果列要显示两条单独的信息,您能不能只制作两个单独的富文本列,将它们放在网格内,然后网格位于 flipview 内。这样您就可以将每个 RichTextColumn 绑定(bind)到您想要的源。

关于Windows 8 商店应用程序 : Using multiple RichTextColumns in a flipview control,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15071196/

相关文章:

.net - 在 C# .Net 中,如何检测对话框是否出现?

windows - 通过命令提示符更改 "Show hidden files and folders"设置

c# - 在 Textblock 中绑定(bind)运行导致 WPF 异常

c# - Stackpanel IsMouseOver 为 False - 当鼠标悬停在 stackPanel Items 之间的间隙上时

windows-8 - Nuget,可移植库和WinRT appx : Payload contains two or more files with the same destination path

Java 连接 netstat -ano

无法使用 fopen 读取 UTF8 编码的文件(文件, "r,ccs=UTF-8")

c# - 如何在使用 WPF 检查的单选按钮上设置字符串 ViewModel 属性?

javascript - 有没有人让 javascript msProtocols 属性在 IE10 中工作?

windows-8 - Windows 8 堆随机化