Here mô tả cách tôi có thể tạo văn bản nhiều cột với cuộn ngang trong ứng dụng kiểu Windows 8 Metro. Có cách nào để thêm "phá vỡ cột" để có được bất kỳ danh hiệu trên đỉnh cột, không phải ở giữa (có trong tâm trí, mà chúng ta không biết có bao nhiêu cột trong mỗi phần):Dấu ngắt cột trong văn bản mulicolumn trong Windows 8 XAML
5
A
Trả lời
5
Bạn có thể tạo một ItemsControl và làm cho RichTextColumns thành một DataTemplate. Mỗi cột nằm trong danh sách được gắn với ItemsControl.
Đây là mẫu 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,0,0">
<RichTextBlockOverflow.RenderTransform>
<TranslateTransform X="-1" Y="4"/>
</RichTextBlockOverflow.RenderTransform>
</RichTextBlockOverflow>
</DataTemplate>
</common:RichTextColumns.ColumnTemplate>
</common:RichTextColumns>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Dưới đây là C# code-behind mẫu:
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 la la la la la la la, so - 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. "
},
new SampleColumnData{
Title = "Column2",
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 la la la la la la la, so - 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. "
},
new SampleColumnData{
Title = "Column3",
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 la la la la la la la, so - 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. "
},
};
itemsControl.ItemsSource = samples;
}
Và đây là một ảnh chụp màn hình:
Hope this helps!
Các vấn đề liên quan
- 1. Văn bản nhiều cột Windows 8 XAML
- 2. Cách "nổi" hình ảnh trong XAML (Windows 8 Metro)
- 3. Đọc một Tệp Văn bản trong Windows 8
- 4. Không có DatePicker cho xaml trong Windows 8 Metro?
- 5. Làm cách nào để căn chỉnh văn bản trong tiêu đề cột DataGrid trong xaml?
- 6. thả xuống Selection Control - Windows 8 Metro - XAML
- 7. Thiết lập Pushpins trên Windows Phone 8 Bản đồ Bing (XAML C#)
- 8. Android: cách đặt dấu đầu dòng, ngắt dòng vào văn bản trong chế độ xem văn bản
- 9. LaTeX: Ngăn chặn ngắt dòng trong một khoảng văn bản
- 10. UTF-8 trong Windows
- 11. Kiểm tra các dấu ngắt dòng trong vùng văn bản với jQuery
- 12. Ngắt dòng hiển thị HTML trong văn bản
- 13. Java: Các dấu ngắt dòng trong JLabels?
- 14. Làm thế nào để animate chiều cao tầm kiểm soát trong Windows 8 XAML
- 15. Xử lý ngắt trong Windows
- 16. Làm thế nào để thay đổi số tiền ký quỹ trong Windows Phone 8 XAML?
- 17. Cách tạo ScrollViewer vòng/tròn trong Windows 8 Metro (C++/XAML)
- 18. Tên XXX không tồn tại trong không gian tên YYY (XAML VS12 Windows 8)
- 19. Trình kích hoạt không được hỗ trợ trong Windows 8 XAML?
- 20. hiển thị nhãn văn bản với ngắt dòng trong C#
- 21. Windows 8 & Windows Phone 8
- 22. Ràng buộc trong cột văn bản lưới dữ liệu WPF
- 23. In văn bản UTF-8 trong chất nhờn REPL
- 24. Danh sách XAML của Windows 8 với các cột Tiêu đề và Mục Mẫu phải có cùng chiều rộng động
- 25. C# windows phone -Đăng nhập trong xaml ListBox.ItemTemplate
- 26. Thư Lê, cách gửi văn bản thuần/văn bản + html trong UTF-8
- 27. dấu ngoặc tròn trong cú pháp XAML
- 28. Dấu lề phải trong trình soạn thảo văn bản VS2010
- 29. WinRT và WPF trong Windows 8
- 30. Làm thế nào để hiển thị một văn bản trong XAML có chứa dấu ngoặc kép và đơn?