最終更新:ID:mAmGC2NECQ 2010年09月24日(金) 18:06:26履歴
- App.xamlのStartupUri="MainWindow.xaml"を削除する
- MainWindow.xamlを、MainWindow.xaml.csごと削除する
新しくウィンドウをMainWindowとして作成して、
MainWindow.xamlに以下のように書いてください。動作は全くしませんが、それなりの見た目ができます。
ビルドして起動まで確認できるはずです。
MainWindow.xamlに以下のように書いてください。動作は全くしませんが、それなりの見た目ができます。
ビルドして起動まで確認できるはずです。
<Window x:Class="LightPlayer.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="LightPlayer" Background="Black" SizeToContent="WidthAndHeight"> <StackPanel> <Border CornerRadius="5" BorderThickness="2" Background="DarkGray" Margin="5" Padding="5"> <StackPanel> <TextBlock>曲名</TextBlock> <TextBlock>アーティスト名</TextBlock> </StackPanel> </Border> <DockPanel Margin="5"> <TextBlock Foreground="White" DockPanel.Dock="Right" VerticalAlignment="Center">0:15</TextBlock> <Slider MinWidth="200"/> </DockPanel> <StackPanel Orientation="Horizontal" Margin="5"> <Button>←</Button> <Button>></Button> <Button>→</Button> <Button Margin="10,0">Open</Button> <Button Margin="10,0">Option</Button> </StackPanel> </StackPanel> </Window>※いったん削除したのは、フォルダを変更するためです
public partial class App : Application { protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); var window = new MainWindow(); window.Show(); } }
MSDNとか見ればだいたいわかると思いますが、簡単に解説
- SizeToContent→WindowのHeightとWidthを勝手に中身のサイズに合わせてくれるように設定
- Border→今回は枠に丸みを持たせるために使用。曲名とアーティスト名を表示するための灰色の領域に相当
- StackPanel→上か順番に(ボタンとかを)おいていくためのパネル。Orientationを指定すると左から右に置いていくことができる
- DockPanel→ DockPanel.Dockで指定した上下左右のどれかから詰めてアイテムをおいていくパネル。最後の要素が残りの領域すべてを使用するのが特徴。
- Margin="10,0"→左右のマージンを10、上下のマージンを0に指定。上下左右すべてを個別に指定したければMargin="10,8,6,4"のように指定できる
このページへのコメント
OuXh2p Im grateful for the article. Fantastic.
rOGppY <a href="http://hklxxcfgazdd.com/">hklxxcfgazdd</a>, [url=http://fmatposnqmhi.com/]fmatposnqmhi[/url], [link=http://ldbnjlpiixuf.com/]ldbnjlpiixuf[/link], http://fucxvtakovuh.com/