【发布时间】:2017-12-04 04:01:27
【问题描述】:
我知道这很简单,但我花了很多时间来水平显示我的列表。我什至将 make StackPanel 方向设置为“水平”,但都是徒劳的。有人能帮忙吗?我真的很感激。
<Window x:Class="RssFeed_Wpf.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:RssFeed_Wpf"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<XmlDataProvider x:Key="DataRss" XPath="//item" Source="http://www.abc.net.au/news/feed/52278/rss.xmlhttp://www.abc.net.au/news/feed/45910/rss.xml">
</XmlDataProvider>
</Window.Resources>
<ListBox ItemsSource="{Binding Source = {StaticResource DataRss}}" Background="Black" HorizontalContentAlignment="Left" BorderBrush="Transparent">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding XPath=title}" FontWeight="Bold" Name="txtScrolling" FontFamily="calibri" Foreground="#f4b042" Height="20pt">
</TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Window>
你可以在这里看到,列表是垂直显示的,但我想要水平显示:
【问题讨论】:
-
谢谢@RogerLeblanc :)