WPF StaticResource (App)

App.xaml でリソースを定義


App.xaml




<Application x:Class="WpfApplication1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<Style x:Key="canvas1" TargetType="Canvas" >
<Setter Property="Width" Value="840"/>
<Setter Property="Height" Value="580"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Top"/>
<Setter Property="Margin" Value="10" />
<Setter Property="Background" Value="#FF0d8d8d" />
</Style>

<Style x:Key="wrapPanelSide1" TargetType="WrapPanel" >
<Setter Property="Width" Value="90"/>
<Setter Property="Height" Value="500"/>
<Setter Property="Margin" Value="10" />
<Setter Property="Background" Value="#FFa4caca" />
</Style>
<Style x:Key="wrapPanelHead1" TargetType="WrapPanel" >
<Setter Property="Width" Value="600"/>
<Setter Property="Height" Value="30"/>
<Setter Property="Background" Value="#FFd7efd7" />
</Style>
<Style x:Key="wrapPanelBody1" TargetType="WrapPanel" >
<Setter Property="Width" Value="600"/>
<Setter Property="Height" Value="500"/>
<Setter Property="Background" Value="#FFa4caca" />
</Style>
<Style x:Key="textBoxSide1" TargetType="TextBox">
<Setter Property="Width" Value="90" />
<Setter Property="Height" Value="30" />
<Setter Property="Background" Value="#FFffffff" />
</Style>
<Style x:Key="textBoxBody1" TargetType="TextBox">
<Setter Property="Width" Value="60" />
<Setter Property="Height" Value="30" />
<Setter Property="Background" Value="#FFffffff" />
</Style>
</Application.Resources>
</Application>


MainWindow
Body1 が、なんで 50 でなく 60 で位置が合うのか?? これも、まあそのうち分かるだろう・・みたいな




<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Wpf-RS-1122" Height="650" Width="900">
<Grid>
<Canvas Style="{StaticResource canvas1}">
<WrapPanel Style="{StaticResource wrapPanelSide1}"
Canvas.Left="10"
Canvas.Top="50">
<TextBox Name="TextBoxPage01_Side1_01" Style="{StaticResource textBoxSide1}"/>
<TextBox Name="TextBoxPage01_Side1_02" Style="{StaticResource textBoxSide1}"/>
<TextBox Name="TextBoxPage01_Side1_03" Style="{StaticResource textBoxSide1}"/>
</WrapPanel>
<WrapPanel Style="{StaticResource wrapPanelSide1}"
Canvas.Left="110"
Canvas.Top="50">
<TextBox Name="TextBoxPage01_Side2_01" Style="{StaticResource textBoxSide1}"/>
<TextBox Name="TextBoxPage01_Side2_02" Style="{StaticResource textBoxSide1}"/>
<TextBox Name="TextBoxPage01_Side2_03" Style="{StaticResource textBoxSide1}"/>
</WrapPanel>
<WrapPanel Style="{StaticResource wrapPanelHead1}"
Canvas.Left="220"
Canvas.Top="10">
<TextBox Name="TextBoxPage01_Head1_01" Style="{StaticResource textBoxBody1}"/>
<TextBox Name="TextBoxPage01_Head1_02" Style="{StaticResource textBoxBody1}"/>
<TextBox Name="TextBoxPage01_Head1_03" Style="{StaticResource textBoxBody1}"/>
</WrapPanel>
<WrapPanel Style="{StaticResource wrapPanelBody1}"
Canvas.Left="220"
Canvas.Top="60">
<TextBox Name="TextBoxPage01_Body1_01" Style="{StaticResource textBoxBody1}"/>
<TextBox Name="TextBoxPage01_Body1_02" Style="{StaticResource textBoxBody1}"/>
<TextBox Name="TextBoxPage01_Body1_03" Style="{StaticResource textBoxBody1}"/>
<TextBox Name="TextBoxPage01_Body1_04" Style="{StaticResource textBoxBody1}"/>
<TextBox Name="TextBoxPage01_Body1_05" Style="{StaticResource textBoxBody1}"/>
<TextBox Name="TextBoxPage01_Body1_06" Style="{StaticResource textBoxBody1}"/>
<TextBox Name="TextBoxPage01_Body1_07" Style="{StaticResource textBoxBody1}"/>
<TextBox Name="TextBoxPage01_Body1_08" Style="{StaticResource textBoxBody1}"/>
<TextBox Name="TextBoxPage01_Body1_09" Style="{StaticResource textBoxBody1}"/>
<TextBox Name="TextBoxPage01_Body1_10" Style="{StaticResource textBoxBody1}"/>
<TextBox Name="TextBoxPage01_Body1_11" Style="{StaticResource textBoxBody1}"/>
<TextBox Name="TextBoxPage01_Body1_12" Style="{StaticResource textBoxBody1}"/>
<TextBox Name="TextBoxPage01_Body1_13" Style="{StaticResource textBoxBody1}"/>
<TextBox Name="TextBoxPage01_Body1_14" Style="{StaticResource textBoxBody1}"/>
<TextBox Name="TextBoxPage01_Body1_15" Style="{StaticResource textBoxBody1}"/>
</WrapPanel>
</Canvas>
</Grid>
</Window>



AX

TYKYUNC index