■ BitmapCacheBrush 엘리먼트를 사용해 캐시된 컨텐츠로 영역을 그리는 방법을 보여준다.
▶ MainWindow.xaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
<Window x:Class="TestProject.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="800" Height="600" Title="TestProject" FontFamily="나눔고딕코딩" FontSize="16"> <Window.Resources> <RichTextBox x:Key="RichTextBoxKey"> <RichTextBox.CacheMode> <BitmapCache EnableClearType="True" RenderAtScale="1" SnapsToDevicePixels="True" /> </RichTextBox.CacheMode> </RichTextBox> <BitmapCacheBrush x:Key="BitmapCacheBrushKey" Target="{StaticResource RichTextBoxKey}"> <BitmapCacheBrush.BitmapCache> <BitmapCache EnableClearType="False" RenderAtScale="0.4" SnapsToDevicePixels="False" /> </BitmapCacheBrush.BitmapCache> </BitmapCacheBrush> </Window.Resources> <Grid Margin="10"> <Grid.RowDefinitions> <RowDefinition Height="*" /> <RowDefinition Height="*" /> <RowDefinition Height="*" /> <RowDefinition Height="*" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Button Name="button1" Grid.Row="0" Grid.Column="0" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> <Button Name="button2" Grid.Row="0" Grid.Column="1" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> <Button Name="button3" Grid.Row="0" Grid.Column="2" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> <Button Name="button4" Grid.Row="0" Grid.Column="3" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> <Button Name="button5" Grid.Row="0" Grid.Column="4" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> <Button Name="button6" Grid.Row="1" Grid.Column="0" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> <Button Name="button7" Grid.Row="1" Grid.Column="1" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> <Button Name="button8" Grid.Row="1" Grid.Column="2" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> <Button Name="button9" Grid.Row="1" Grid.Column="3" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> <Button Name="button10" Grid.Row="1" Grid.Column="4" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> <Button Name="button11" Grid.Row="2" Grid.Column="0" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> <Button Name="button12" Grid.Row="2" Grid.Column="1" Background="{StaticResource BitmapCacheBrushKey}" Content="Button" FontWeight="Bold" /> <Button Name="button13" Grid.Row="2" Grid.Column="2" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> <Button Name="button14" Grid.Row="2" Grid.Column="3" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> <Button Name="button15" Grid.Row="2" Grid.Column="4" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> <Button Name="button16" Grid.Row="3" Grid.Column="0" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> <Button Name="button17" Grid.Row="3" Grid.Column="1" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> <Button Name="button18" Grid.Row="3" Grid.Column="2" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> <Button Name="button19" Grid.Row="3" Grid.Column="3" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> <Button Name="button20" Grid.Row="3" Grid.Column="4" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> <Button Name="button21" Grid.Row="4" Grid.Column="0" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> <Button Name="button22" Grid.Row="4" Grid.Column="1" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> <Button Name="button23" Grid.Row="4" Grid.Column="2" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> <Button Name="button24" Grid.Row="4" Grid.Column="3" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> <Button Name="button25" Grid.Row="4" Grid.Column="4" Background="{StaticResource BitmapCacheBrushKey}" FontWeight="Bold" Content="Button" /> </Grid> </Window> |