<Window x:Class="BitmapCache.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Height="421" Width="625" >
    <Window.Resources>
        <StackPanel Margin="5" x:Key="stackPanel" >
            <Label Content="Oryginalny"/>
            <!--definicje kolejnych elementów-->
            <WrapPanel>
                <WrapPanel.CacheMode>
                    <BitmapCache RenderAtScale="1"/>
                </WrapPanel.CacheMode>
                <Ellipse StrokeThickness="3" Stroke="Black" Width="40" Height="40" Fill="Red"/>
                <Ellipse StrokeThickness="3" Stroke="Black"  Width="40" Height="40" Fill="Red"/>
                <Ellipse StrokeThickness="3" Stroke="Black"  Width="40" Height="40" Fill="Red"/>
                <Ellipse StrokeThickness="3" Stroke="Black" Width="40" Height="40" Fill="Red"/>
            </WrapPanel>
            <Label Content="RenderAtScale='0.5'"/>
            <WrapPanel>
                <WrapPanel.CacheMode>
                    <BitmapCache RenderAtScale="0.5"/>
                </WrapPanel.CacheMode>
                <Ellipse Name="ellipse1" StrokeThickness="3" Stroke="Black"  Width="40" Height="40" Fill="Red"/>
                <Ellipse Name="ellipse2" StrokeThickness="3" Stroke="Black"  Width="40" Height="40" Fill="Red"/>
                <Ellipse Name="ellipse3" StrokeThickness="3" Stroke="Black"  Width="40" Height="40" Fill="Red"/>
                <Ellipse Name="ellipse4" StrokeThickness="3" Stroke="Black"  Width="40" Height="40" Fill="Red"/>
            </WrapPanel>
            <Label Content="RenderAtScale='1', powiększenie 2x"/>
            <WrapPanel>
                <WrapPanel.CacheMode>
                    <BitmapCache RenderAtScale="1"/>
                </WrapPanel.CacheMode>
                <WrapPanel.LayoutTransform>
                    <ScaleTransform ScaleY="2" ScaleX="2"/>
                </WrapPanel.LayoutTransform>
                <Ellipse StrokeThickness="3" Stroke="Black"  Width="40" Height="40" Fill="Red"/>
                <Ellipse StrokeThickness="3" Stroke="Black"  Width="40" Height="40" Fill="Red"/>
                <Ellipse StrokeThickness="3" Stroke="Black"  Width="40" Height="40" Fill="Red"/>
                <Ellipse StrokeThickness="3" Stroke="Black"  Width="40" Height="40" Fill="Red"/>
            </WrapPanel>
            <Label Content="RenderAtScale='2', powiększenie 2x"/>
            <WrapPanel>
                <WrapPanel.CacheMode>
                    <BitmapCache RenderAtScale="2"/>
                </WrapPanel.CacheMode>
                <WrapPanel.LayoutTransform>
                    <ScaleTransform ScaleY="2" ScaleX="2"/>
                </WrapPanel.LayoutTransform>
                <Ellipse StrokeThickness="3" Stroke="Black"  Width="40" Height="40" Fill="Red"/>
                <Ellipse StrokeThickness="3" Stroke="Black"  Width="40" Height="40" Fill="Red"/>
                <Ellipse StrokeThickness="3" Stroke="Black"  Width="40" Height="40" Fill="Red"/>
                <Ellipse StrokeThickness="3" Stroke="Black"  Width="40" Height="40" Fill="Red"/>
            </WrapPanel>
        </StackPanel>
    </Window.Resources>
    <!--przyciski zostaną umieszczone w panelu WrapPanel-->
    <WrapPanel>
        <Button Width="80" Height="80">
            <Button.Background>
                <!--element malowany określony we właściwości Target-->
                <BitmapCacheBrush Target="{StaticResource stackPanel}" >
                    <!--zapis danych do pamięci wg ustawień BitmapCache pędzla-->
                    <BitmapCacheBrush.BitmapCache>
                        <BitmapCache RenderAtScale="1"/>
                    </BitmapCacheBrush.BitmapCache>
                </BitmapCacheBrush>
            </Button.Background>
        </Button>
        <!--definicje pozostałych 4 przycisków
        RenderAtScale wynosi kolejno 
        0.8, 0.6, 0.4, 0.1-->
        <Button Width="80" Height="80">
            <Button.Background>
                <BitmapCacheBrush Target="{StaticResource stackPanel}" >
                    <BitmapCacheBrush.BitmapCache>
                        <BitmapCache RenderAtScale="0.8"/>
                    </BitmapCacheBrush.BitmapCache>
                </BitmapCacheBrush>
            </Button.Background>
        </Button>
        <Button Width="80" Height="80">
            <Button.Background>
                <BitmapCacheBrush Target="{StaticResource stackPanel}" >
                    <BitmapCacheBrush.BitmapCache>
                        <BitmapCache RenderAtScale="0.6"/>
                    </BitmapCacheBrush.BitmapCache>
                </BitmapCacheBrush>
            </Button.Background>
        </Button>
        <Button Width="80" Height="80">
            <Button.Background>
                <BitmapCacheBrush Target="{StaticResource stackPanel}" >
                    <BitmapCacheBrush.BitmapCache>
                        <BitmapCache RenderAtScale="0.4"/>
                    </BitmapCacheBrush.BitmapCache>
                </BitmapCacheBrush>
            </Button.Background>
        </Button>
        <Button Width="80" Height="80">
            <Button.Background>
                <BitmapCacheBrush Target="{StaticResource stackPanel}" >
                    <BitmapCacheBrush.BitmapCache>
                        <BitmapCache RenderAtScale="0.1"/>
                    </BitmapCacheBrush.BitmapCache>
                </BitmapCacheBrush>
            </Button.Background>
        </Button>
    </WrapPanel>
</Window>