В окне Solution Explorer создаем папку Dictionary в которой создаем файл Background_main.xaml типа ResourceDictionary, который будет описывать фон.
- <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
- <Canvas x:Key="Background_main">
- <Path Fill="#ff000000" Data="F1 M 841.890,595.275 L 0.000,595.275 L 0.000,0.000 L 841.890,0.000 L 841.890,595.275 Z"/>
- <Path Data="F1 M 265.910,218.277 C 265.910,169.332 223.865,129.655 172.000,129.655 C 120.135,129.655 78.090,169.332 78.090,218.277 C 78.090,267.222 120.135,306.898 172.000,306.898 C 223.865,306.898 265.910,267.222 265.910,218.277 Z">
- <Path.Fill>
- <RadialGradientBrush MappingMode="Absolute"
- GradientOrigin="172.733,217.234"
- Center="172.733,217.234"
- RadiusX="81.912"
- RadiusY="81.912">
- <RadialGradientBrush.GradientStops>
- <GradientStop Offset="0.00" Color="#ff0d4976"/>
- <GradientStop Offset="0.41" Color="#ff06243b"/>
- <GradientStop Offset="1.00" Color="#ff000000"/>
- </RadialGradientBrush.GradientStops>
- <RadialGradientBrush.Transform>
- <MatrixTransform Matrix="1.146,0.000,0.000,1.082,-26.038,-16.750" />
- </RadialGradientBrush.Transform>
- </RadialGradientBrush>
- </Path.Fill>
- </Path>
- </Canvas>
- </ResourceDictionary>
* This source code was highlighted with Source Code Highlighter.
Наш основной файл Window1.xaml
выглядит так:- <Window x:Class="WpfTestBackground.Window1"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- Title="Window1" Height="300" Width="300">
- <Window.Resources>
- <ResourceDictionary Source="Dictionary/Background_main.xaml" />
- </Window.Resources>
- <Grid >
- <Grid.Background>
- <VisualBrush Visual="{StaticResource Background_main}" />
- </Grid.Background>
- </Grid>
- </Window>
* This source code was highlighted with Source Code Highlighter.