Here ha descritto come posso creare testo a più colonne con scorrimento orizzontale nell'app di Windows Metro in stile 8. C'è modo per aggiungere "interruzioni di colonna" per ottenere qualsiasi titolo sulla parte superiore della colonna, non nel mezzo (avendo in mente, che non sappiamo quante colonne in ogni sezione):Interruzioni di colonna nel testo multi-testo in Windows 8 XAML
5
A
risposta
5
È possibile creare un oggetto ItemsControl e rendere RichTextColumns come DataTemplate. Ogni colonna si trova in un elenco associato a ItemsControl.
Ecco campione 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>
Ecco C# code-behind di esempio:
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;
}
Ed ecco uno screenshot:
Spero che questo aiuti!
Problemi correlati
- 1. windows 8 collegamento ipertestuale in linea xaml
- 2. Come "float" immagine in XAML (Windows 8 Metro)
- 3. Windows 8 C#/XAML - Crea un bordo attorno al testo del testo
- 4. I trigger non sono supportati in XAML di Windows 8?
- 5. TreeView nell'app di Windows 8 store in XAML
- 6. discesa di selezione di controllo - Windows 8 Metro - XAML
- 7. Come animare l'altezza del controllo in Windows 8 XAML
- 8. Non c'è DatePicker per xaml in Windows 8 Metro?
- 9. Windows Phone contenuti 8 scorrimento di testo
- 10. Multiprocessing su interruzioni di Windows
- 11. Il nome XXX non esiste nel namespace YYY (XAML VS12 Windows 8)
- 12. Leggere un file di testo in Windows 8
- 13. C# windows phone - Allineamento in xaml ListBox.ItemTemplate
- 14. Voce di selezione del testo programmatico con interruzioni di riga
- 15. Echo Caratteri UTF-8 nel batch di Windows
- 16. Associazione di testo condizionale XAML
- 17. Windows 8 - Animazione di proprietà personalizzate nel code-behind
- 18. Quali editor di testo gestiscono correttamente le interruzioni di linea in stile Windows e Unix?
- 19. PHP Converti testo codificato Windows-1256 in UTF-8
- 20. Stampa newline in TextBlock in windows 8
- 21. Come allineare correttamente il testo in un'intestazione di colonna DataGrid in xaml?
- 22. Imposta nome intestazione colonna in XAML-WPF
- 23. Puoi mescolare HTML e XAML in un'app di Windows 8 Metro?
- 24. Formattazione stringa XAML in windows phone
- 25. Windows 8 e Windows Phone 8
- 26. GetVersionEx in Windows 8
- 27. PHP Converti Windows-1251 in UTF 8
- 28. Metro di Windows 8: convalida dell'implementazione
- 29. Windows 8 Image UniformFill centrato
- 30. Controllo WebBrowser in UWP (Windows 10) XAML