我正在尝试创建一个WPF应用程序,其中我有一个显示帐户列表的StackPanel.每个帐户的代码后面都有一个Account对象,存储在List结构中.我想将此数据绑定到我的WPF,但我不想要一个列表框.
相反,我为每个帐户摘要的显示方式定义了一个模板.然后我想将它们堆叠在StackPanel中并将其称为一天.
问题是数据绑定只从列表中获取第一个项目,就是这样.如何绑定它,以便有效地创建一个很好的格式化数据块的堆栈列表?
以下是相关的WPF代码:
<StackPanel Name="sp_AccountList" Margin="0,0,0,0" VerticalAlignment="Top">
<StackPanel.Resources>
<svc:AccountBalanceColorConverter x:Key="accountColorConverter" />
<Style x:Key="AccountSummaryBackgroundGradient" TargetType="{x:Type StackPanel}">
<!-- nice formatting code here -->
</Style>
<Style x:Key="AccountSummaryNameStyle" TargetType="{x:Type TextBlock}">
<Setter Property="Padding" Value="10,0,0,0" />
<Setter Property="FontSize" Value="18" />
<Setter Property="Height" Value="20" />
<Setter Property="FontFamily" Value="Cambria" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Background" Value="Transparent" />
</Style>
<Style x:Key="AccountSummaryBalanceStyle" TargetType="{x:Type TextBlock}">
<Setter Property="Padding" Value="10,0,0,0" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Height" Value="20" />
<Setter Property="FontFamily" Value="Cambria" />
<Setter Property="Background" Value="Transparent" />
</Style>
<ObjectDataProvider x:Key="accounts"
ObjectType="{x:Type …Run Code Online (Sandbox Code Playgroud)