页面内
<Page x:Class="ICTRExchange.Pages.HistoryPage"
x:Name="_this"
.
.
. skip
.
./>
在网格中
<Grid.Resources>
<DataTemplate x:Key="MultiColumnHeaderTemplate">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<TextBlock Text="{Binding}" HorizontalAlignment="Center"/>
<GridViewHeaderRowPresenter Grid.Row="1" HorizontalAlignment="Center" Columns="{DynamicResource WithdrawColumnCollection}" />
</Grid>
</DataTemplate>
</Grid.Resources>
<ListView Name="lvExchangeHistory" Width="1000" ItemsSource="{Binding ExchangeHistoryList, ElementName=_this}">
<ListView.View>
<GridView ColumnHeaderContainerStyle="{StaticResource GridViewColumnHeaderStyle1}">
<GridViewColumn DisplayMemberBinding="{Binding Path=StartDate,StringFormat={}{0:yyyy/MM/dd HH:mm:ss}}" Header="Date" Width="250"/>
<GridViewColumn DisplayMemberBinding="{Binding Path=DepositDenom, StringFormat={}{0:N0}원}" Header="Amount" Width="350"/>
<GridViewColumn Header="WithdrawAmount" Width="400" HeaderTemplate="{DynamicResource MultiColumnHeaderTemplate}"/>
</GridView>
</ListView.View>
</ListView>
cs文件。
public List<ExchangeTransactionModel> ExchangeHistoryList
{
get => TransactionManager.Instance.GetTransactionList();
}
如何为MultiColumnHeaderTemplate进行数据绑定。
现在,
<GridViewColumn DisplayMemberBinding="{Binding Path=StartDate,StringFormat={}{0:yyyy/MM/dd HH:mm:ss}}" Header="Date" Width="250"/>
<GridViewColumn DisplayMemberBinding="{Binding Path=DepositDenom, StringFormat={}{0:N0}원}" Header="Amount" Width="350"/>
上面的源代码通常是数据绑定。 下面的源代码不是数据绑定。 为什么不能在源代码下方进行数据绑定。
<GridViewColumn Header="WithdrawAmount" Width="400" HeaderTemplate="{DynamicResource MultiColumnHeaderTemplate}"/>