System.Windows.FrameworkTemplate.LoadTemplateXaml
would be called many times, especially when virtualization is disabled.
Last active
August 29, 2015 14:15
-
-
Save JeffreyZhao/7f6747fbd7aedde80366 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Window x:Class="WpfApplication1.MainWindow" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
Title="MainWindow" Height="350" Width="525"> | |
<Grid> | |
<Grid.Resources> | |
<ControlTemplate TargetType="DataGridCell" x:Key="TestCell"> | |
<Border Name="PART_CellBorder" SnapsToDevicePixels="True" BorderBrush="Red" BorderThickness="2"> | |
<ContentPresenter Name="PART_ContentPresenter" Content="{Binding}" /> | |
</Border> | |
</ControlTemplate> | |
<Style TargetType="DataGridCell"> | |
<Setter Property="Template" Value="{StaticResource TestCell}" /> | |
</Style> | |
</Grid.Resources> | |
<DataGrid EnableColumnVirtualization="True" EnableRowVirtualization="True" Name="DataGrid" HorizontalAlignment="Left" Margin="29,32,0,0" VerticalAlignment="Top" Height="256" Width="450"/> | |
<Button Content="Button" HorizontalAlignment="Left" Margin="29,10,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/> | |
</Grid> | |
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace WpfApplication1 | |
{ | |
using System.Linq; | |
using System.Windows; | |
/// <summary> | |
/// Interaction logic for MainWindow.xaml | |
/// </summary> | |
public partial class MainWindow | |
{ | |
public MainWindow() | |
{ | |
InitializeComponent(); | |
} | |
private void Button_Click(object sender, RoutedEventArgs e) | |
{ | |
DataGrid.ItemsSource = Enumerable.Range(0, 1000).Select(_ => new Person()).ToList(); | |
} | |
} | |
public class Person | |
{ | |
public string FirstName { get; set; } | |
public string LastName { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment