WPF 메모 컨트롤 확대

8176 단어 XamlWPF

개요



컨트롤의 크기를 두 배로 만드는 샘플.

코드



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>

실행 결과





참고(통상 사이즈)


환경


  • Windows 8.1
  • Visual Studio Express 2015 for Windows Desktop
  • 좋은 웹페이지 즐겨찾기