ウィンドウ(フォーム)背景に模様
App.xaml
<Application
x:Class="SampleApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SampleApp"
StartupUri="MainWindow.xaml">
<Application.Resources>
<!-- 既定のButtonスタイル -->
<Style TargetType="Button">
<Setter Property="Margin" Value="8" />
<Setter Property="Width" Value="150" />
<Setter Property="HorizontalAlignment" Value="left" />
</Style>
<!-- 模様付きBorderスタイル -->
<Style x:Key="CheckeredPatternStyle" TargetType="Border">
<Setter Property="Background">
<Setter.Value>
<DrawingBrush
Stretch="None"
TileMode="Tile"
Viewport="0,0,100,100"
ViewportUnits="Absolute">
<DrawingBrush.Drawing>
<DrawingGroup>
<GeometryDrawing Brush="Black">
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0,0,100,100" />
</GeometryDrawing.Geometry>
</GeometryDrawing>
<GeometryDrawing Brush="ForestGreen">
<GeometryDrawing.Geometry>
<GeometryGroup RenderOptions.EdgeMode="Aliased">
<RectangleGeometry Rect="0,0,50,50" />
<RectangleGeometry Rect="50,50,50,50" />
</GeometryGroup>
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</Setter.Value>
</Setter>
</Style>
</Application.Resources>
</Application>
MainWindow.xaml
<Window
x:Class="SampleApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SampleApp"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="MainWindow"
Width="600"
Height="400"
MinWidth="250"
MinHeight="200"
ResizeMode="CanResizeWithGrip"
mc:Ignorable="d">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="0.4*" />
</Grid.ColumnDefinitions>
<Border Grid.ColumnSpan="2" Style="{StaticResource CheckeredPatternStyle}" />
<StackPanel>
<Button Content="Button" />
<Button Content="Button" />
<Button Content="Button" />
</StackPanel>
<TextBox
Grid.Column="1"
Margin="8"
Opacity="0.9"
Text="こんにちは"
VerticalScrollBarVisibility="Visible" />
</Grid>
</Window>
csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
</Project>
Author And Source
この問題について(ウィンドウ(フォーム)背景に模様), 我々は、より多くの情報をここで見つけました https://qiita.com/Kosen-amai/items/0d26d374991d38ca7b4e著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .