はじめてのC#アプリケーション
この記事のなりわし
とある件で,先輩の作ったWindowsアプリケーションの改修をすることとなり,
全く経験のないなかで,いろいろまとめていった忘却禄
UWPとWPF
そもそも2種類あるのすら知らなかった.
UWPのほうが新しくて速いらしい
WPFはhtml,css,js みたいにかけて、簡単だけど、動作が遅い
アーキテクチャが全くの別物らしい
ちなみに,UWPはWindows10でしか動かない.
WPFのきほん
画面は.xamlファイル,処理は.xaml.csで書くらしい
https://qiita.com/koara-local/items/c58ca6b83e46b7c6125c
UI Debug
Live Visual Tree を使えばよいらしい
https://www.atmarkit.co.jp/ait/articles/1508/05/news023.html
用語集
【 C# 】 初心者による初心者のためのプログラミング用語の解説
ResourceDictionary
html5でいうところの,css的なことができる
https://www.doraxdora.com/blog/2017/06/08/post-1155/
https://docs.microsoft.com/ja-jp/windows/uwp/design/controls-and-patterns/resourcedictionary-and-xaml-resource-references
https://araramistudio.jimdo.com/2016/12/01/wpf%E3%81%A7%E3%82%88%E3%81%8F%E4%BD%BF%E3%81%86xaml%E3%81%AE%E5%AE%9A%E7%BE%A9%E3%82%92%E5%88%A5%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%81%AB%E3%81%99%E3%82%8B/
例
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="Body_Content_DataGrid_Centering" TargetType="{x:Type DataGridCell}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter VerticalAlignment="Center" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
使い方
StaticResourceで呼び出す
<DataGrid CellStyle="{StaticResource Body_Content_DataGrid_Centering}">
</DataGrid>
Data grid
ソーティング機能付きの表が作れる
<Window x:Class="DataGridBindingSample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="200" Width="360">
<Grid>
<DataGrid Name="dataGrid" IsReadOnly="True"
AutoGenerateColumns="False" >
<DataGrid.Columns>
<DataGridTextColumn Header="番号" Width="80"
Binding="{Binding No, StringFormat=D2}" />
<DataGridTextColumn Header="名前" Width="100"
Binding="{Binding Name}" />
<DataGridTextColumn Header="誕生日" Width="*"
Binding="{Binding BirthDay, StringFormat=yyyy/MM/dd}" />
</DataGrid.Columns>
</DataGrid>
</Grid>
</Window>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.dataGrid.ItemsSource = new[]
{
new Person { No = 1, Name = "Tanaka", BirthDay = new DateTime(2000, 1, 1) },
new Person { No = 2, Name = "Yamada", BirthDay = new DateTime(1990, 5, 5) },
new Person { No = 3, Name = "Sato", BirthDay = new DateTime(2001, 12, 31) },
};
}
}
public class Person
{
public int No { get; set; }
public string Name { get; set; }
public DateTime BirthDay { get; set; }
}
参考文献
Author And Source
この問題について(はじめてのC#アプリケーション), 我々は、より多くの情報をここで見つけました https://qiita.com/hayate242/items/7cb673f30b707e7c19e3著者帰属:元の著者の情報は、元の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 .