我目前尝试将RSS源可视化。我创建了2个对象:FeedChannel
和FeedElement
。 FeedChannel
可能包含FeedElement
s。WPF MVVM单击项目后更改GUI
该进料可以具有多个信道,其将被显示这样的:
<Grid>
<ScrollViewer>
<ListBox ItemsSource="{Binding Feed, IsAsync=True}" x:Name="ListFeed">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseLeftButtonUp">
<i:InvokeCommandAction Command="{Binding ChannelClickCommand}" CommandParameter="{Binding ElementName=ListFeed, Path=SelectedItem}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Margin="0,0,10,0" Source="{Binding ImageLink}" VerticalAlignment="Top" Width="100" Height="50"/>
<StackPanel Grid.Column="1" Orientation="Vertical">
<TextBlock Text="{Binding Title}" FontWeight="ExtraBold" />
<TextBlock Text="{Binding Description}" />
<TextBlock Text="{Binding PublicationDate}" HorizontalAlignment="Right" FontWeight="Thin"/>
</StackPanel>
</Grid>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</ScrollViewer>
</Grid>
的ChannelClickCommand
将保存点击频道进入ActiveChannel
属性。在我看来,我现在应该访问ActiveChannel
并在其中显示FeedElement
。
这一切很容易做,但我在寻找下正确的做法奋斗:(!只有通道)
鉴于用户首先看到的所有频道,他现在可以点击其中的一个,然后将显示所有元素(不再显示通道)。他可能会返回查看所有频道的按钮点击或类似的东西。
我想过使用Stackpanels并根据需要将它们变为可见/折叠状态,但有没有更好的解决方案来解决这个问题?
今天我会试试。谢谢! – Kohnarik