WPF 메모 컨트롤 확대
개요
컨트롤의 크기를 두 배로 만드는 샘플.
코드
MainWindow.xaml<Window x:Class="WpfApplication1.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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication1"
mc:Ignorable="d"
Title="MainWindow" Height="465.718" Width="525">
<Window.Resources>
<!-- サイズ2倍 -->
<ScaleTransform x:Key="ScaleXY" ScaleX="2" ScaleY="2" />
<!-- ベースのスタイル -->
<Style x:Key="BaseStyle" TargetType="{x:Type FrameworkElement}">
<Setter Property="LayoutTransform" Value="{StaticResource ScaleXY}" />
</Style>
<!-- コントロールのスタイル -->
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource BaseStyle}" />
<Style TargetType="{x:Type CheckBox}" BasedOn="{StaticResource BaseStyle}" />
<Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource BaseStyle}" />
<Style TargetType="{x:Type Label}" BasedOn="{StaticResource BaseStyle}" />
<Style TargetType="{x:Type ListBox}" BasedOn="{StaticResource BaseStyle}" />
<Style TargetType="{x:Type RadioButton}" BasedOn="{StaticResource BaseStyle}" />
<Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource BaseStyle}" />
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource BaseStyle}" />
</Window.Resources>
<StackPanel>
<Button x:Name="button" Content="Button"/>
<CheckBox x:Name="checkBox" Content="CheckBox" IsChecked="True"/>
<ComboBox x:Name="comboBox" SelectedIndex="0">
<ComboBoxItem Content="コンボ項目1" />
<ComboBoxItem Content="コンボ項目2" />
<ComboBoxItem Content="コンボ項目3" />
</ComboBox>
<Label x:Name="label" Content="Label"/>
<ListBox x:Name="listBox" Height="50">
<ListBoxItem Content="AAAA" />
<ListBoxItem Content="BBBB" />
<ListBoxItem Content="CCCC" />
</ListBox>
<RadioButton x:Name="radioButton" Content="RadioButton" IsChecked="True"/>
<TextBlock x:Name="textBlock" TextWrapping="Wrap">
テキスト一行目<LineBreak />
テキスト二行目<LineBreak />
</TextBlock>
<TextBox x:Name="textBox" Height="23" TextWrapping="Wrap" Text="TextBox"/>
</StackPanel>
</Window>
실행 결과
참고(통상 사이즈)
환경
MainWindow.xaml
<Window x:Class="WpfApplication1.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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication1"
mc:Ignorable="d"
Title="MainWindow" Height="465.718" Width="525">
<Window.Resources>
<!-- サイズ2倍 -->
<ScaleTransform x:Key="ScaleXY" ScaleX="2" ScaleY="2" />
<!-- ベースのスタイル -->
<Style x:Key="BaseStyle" TargetType="{x:Type FrameworkElement}">
<Setter Property="LayoutTransform" Value="{StaticResource ScaleXY}" />
</Style>
<!-- コントロールのスタイル -->
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource BaseStyle}" />
<Style TargetType="{x:Type CheckBox}" BasedOn="{StaticResource BaseStyle}" />
<Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource BaseStyle}" />
<Style TargetType="{x:Type Label}" BasedOn="{StaticResource BaseStyle}" />
<Style TargetType="{x:Type ListBox}" BasedOn="{StaticResource BaseStyle}" />
<Style TargetType="{x:Type RadioButton}" BasedOn="{StaticResource BaseStyle}" />
<Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource BaseStyle}" />
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource BaseStyle}" />
</Window.Resources>
<StackPanel>
<Button x:Name="button" Content="Button"/>
<CheckBox x:Name="checkBox" Content="CheckBox" IsChecked="True"/>
<ComboBox x:Name="comboBox" SelectedIndex="0">
<ComboBoxItem Content="コンボ項目1" />
<ComboBoxItem Content="コンボ項目2" />
<ComboBoxItem Content="コンボ項目3" />
</ComboBox>
<Label x:Name="label" Content="Label"/>
<ListBox x:Name="listBox" Height="50">
<ListBoxItem Content="AAAA" />
<ListBoxItem Content="BBBB" />
<ListBoxItem Content="CCCC" />
</ListBox>
<RadioButton x:Name="radioButton" Content="RadioButton" IsChecked="True"/>
<TextBlock x:Name="textBlock" TextWrapping="Wrap">
テキスト一行目<LineBreak />
テキスト二行目<LineBreak />
</TextBlock>
<TextBox x:Name="textBox" Height="23" TextWrapping="Wrap" Text="TextBox"/>
</StackPanel>
</Window>
실행 결과
참고(통상 사이즈)
환경
Reference
이 문제에 관하여(WPF 메모 컨트롤 확대), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/Kosen-amai/items/e42b279ae96ba953f18a텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)