Windows 8 XAML中的mulicolumn文本中的列中断
发布时间:2020-12-14 01:52:50 所属栏目:Windows 来源:网络整理
导读:Here描述了如何在Windows 8 Metro风格应用程序中使用水平滚动创建多列文本.有没有办法添加“列分隔符”来获取列顶部的任何标题,而不是在中间(请记住,我们不知道每个部分中有多少列): 解决方法 您可以创建ItemsControl并将RichTextColumns作为DataTemplate.
Here描述了如何在Windows 8 Metro风格应用程序中使用水平滚动创建多列文本.有没有办法添加“列分隔符”来获取列顶部的任何标题,而不是在中间(请记住,我们不知道每个部分中有多少列):
解决方法
您可以创建ItemsControl并将RichTextColumns作为DataTemplate.每列都在一个绑定到ItemsControl的列表中.
这是XAML示例: <ItemsControl x:Name="itemsControl"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel Orientation="Horizontal"/> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <!-- Content is allowed to flow across as many columns as needed --> <common:RichTextColumns x:Name="richTextColumns" Margin="25,20,25,20"> <RichTextBlock x:Name="richTextBlock" Width="200" Style="{StaticResource ItemRichTextStyle}" IsTextSelectionEnabled="False"> <Paragraph> <Run FontSize="26.667" FontWeight="Light" Text="{Binding Title}"/> <LineBreak/> <LineBreak/> </Paragraph> <Paragraph> <Run FontWeight="SemiLight" Text="{Binding Content}"/> </Paragraph> </RichTextBlock> <!-- Additional columns are created from this template --> <common:RichTextColumns.ColumnTemplate> <DataTemplate> <RichTextBlockOverflow Width="200" Margin="80,0"> <RichTextBlockOverflow.RenderTransform> <TranslateTransform X="-1" Y="4"/> </RichTextBlockOverflow.RenderTransform> </RichTextBlockOverflow> </DataTemplate> </common:RichTextColumns.ColumnTemplate> </common:RichTextColumns> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> 这是C#代码隐藏示例: protected override void OnNavigatedTo(NavigationEventArgs e) { var samples = new List<SampleColumnData> { new SampleColumnData{ Title = "Column1",Content = "Just the good ol' boys,never meanin' no harm. Beats all you've ever saw,been in trouble with the law since the day they was born. Straight'nin' the curve,flat'nin' the hills. Someday the mountain might get 'em,but the law never will. Makin' their way,the only way they know how,that's just a little bit more than the law will allow. Just good ol' boys,wouldn't change if they could,fightin' the system like a true modern day Robin Hood. Knight Rider,a shadowy flight into the dangerous world of a man who does not exist. Michael Knight,a young loner on a crusade to champion the cause of the innocent,the helpless in a world of criminals who operate above the law. I never spend much time in school but I taught ladies plenty. It's true I hire my body out for pay,hey hey. I've gotten burned over Cheryl Tiegs,blown up for Raquel Welch. But when I end up in the hay it's only hay,hey hey. I might jump an open drawbridge,or Tarzan from a vine. 'Cause I'm the unknown stuntman that makes Eastwood look so fine. Barnaby The Bear's my name,never call me Jack or James,I will sing my way to fame,Barnaby the Bear's my name. Birds taught me to sing,when they took me to their king,first I had to fly,in the sky so high so high,so high so high so high,so - if you want to sing this way,think of what you'd like to say,add a tune and you will see,just how easy it can be. Treacle pudding,fish and chips,fizzy drinks and liquorice,flowers,rivers,sand and sea,snowflakes and the stars are free. La la la la la,la la la la la la la,la la la la la la la la la la la la la,so - Barnaby The Bear's my name,Barnaby the Bear's my name. " },new SampleColumnData{ Title = "Column2",new SampleColumnData{ Title = "Column3",}; itemsControl.ItemsSource = samples; } 这是一个截图: 希望这可以帮助! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- MCSA / Windows Server 2016 用MAP工具进行IT资产评估I和虚
- active-directory – 如何让Bugzilla通过Active Directory
- windows-8 – Windows 8 HTML / JavaScript Metro Apps中的
- windows-server-2008 – 如何通过电子邮件发送预定任务的输
- Windows中使用计划任务自动执行PHP程序实例
- 强制删除Windows服务
- Windows下的GTK或Qt
- windows-server-2008-r2 – 为什么使用不同用户通过PowerSh
- windows Git Bash 无法运行python解决方法
- YAPI windows 二次开发 树形结构 多层级结构 拖拽 数据导入
推荐文章
站长推荐
热点阅读