Architect's Log

I'm a Cloud Architect. I'm highly motivated to reduce toils with driving DevOps.

WPF

ツールチップを表示する

アプリ実行 起動 マウスオーバー ソースコード App.xaml <Application x:Class="HelloWorld.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> </Application> MainWindow.xaml

ドキュメントビューアを使用する

今回はFlowDocumentReaderを使用しますが、機能を限定したFlowDocumentPageReader、FlowDocumentScrollViewerもあります。 アプリ実行 ページモード 2ページモード スクロールモード 検索 ズーム ソースコード App.xaml

RichTextBoxに検索機能を実装する

アプリ実行 入力 検索結果 ソースコード App.xaml <Application x:Class="HelloWorld.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> </Application> MainWindow.xaml

RichTextBoxのマークアップと各要素のオフセット

アプリ実行 入力 [Ctrl + B]で太字にする 「は」のオフセットは10 マークアップと各要素のオフセット 開始要素と終了要素が含まれるためオフセットが発生します。 マークアップ こ ん に ち は オフセット 0 1 2 3 4 5 6 7 8 9 10 11 12 ソースコード App.xa…

RichTextBoxを使用する

アプリ実行 ソースコード App.xaml <Application x:Class="WpfApplication2.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> </Application> MainWindow.xaml

Sliderを使用する

アプリ実行 ソースコード App.xaml <Application x:Class="WpfApplication2.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> </Application> MainWindow.xaml

コンテナコントロールを使用する

エッセンシャル WPF P.131より引用 ユーザーインターフェースの一部をグループ化したり隠したりするために、WPFには3つの主要な組み込みコントロールがあります。それは、TabControl、Expander、およびGroupBoxです。 エッセンシャル WPF:Windows Presentat…

ツールバーに項目を表示する

アプリ実行 ソースコード App.xaml <Application x:Class="WpfApplication2.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> </Application> MainWindow.xaml

メニューに項目を表示する

アプリ実行 起動 [ファイル]メニュー [編集]メニュー 検証 項目 結果 メニューの[開く]をクリックするとファイル選択ダイアログが表示される OK ソースコード App.xaml <Application x:Class="WpfApplication2.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> </Application>…

TreeViewに項目を表示する

アプリ実行 起動 展開 ソースコード 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="Page1.xaml"> </Application> Page1.xaml

ListViewに項目を表示する

エッセンシャル WPF P.124より引用 列の数、ヘッダの内容、およびビューに関するその他の事項を制御するためのプロパティは、ListViewにはありません。代わりに、ListView.ViewプロパティをGridViewに設定し、このオブジェクトのプロパティを設定する必要が…

ListBoxをさらにカスタマイズする

ItemsPanelTemplateは、項目のレイアウトに使用されるパネルを指定します。それ以上のカスタマイズにはControlTemplateを使用します。 アプリ実行 ソースコード App.xaml <Application x:Class="HelloWorld.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="Page1.xaml"> </Application>…

ListBoxのアイテムを2列に並べる

通常のControlTemplateではなく、ItemsPanelTemplateを使用します。 アプリ実行 ソースコード App.xaml <Application x:Class="HelloWorld.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="Page1.xaml"> </Application> Page1.xaml

コントロールにアクセスキーを設定する

アプリ実行 起動 [Alt + B]押下 ソースコード App.xaml <Application x:Class="HelloWorld.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="Button.xaml"> </Application> Button.xaml

テンプレートバインディングを適用する(その2)

プロパティ名が一致していなくてもテンプレートバインディングを使用することができます。 アプリ実行 ソースコード App.xaml <Application x:Class="HelloWorld.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> </Application> MainWindow.xaml

テンプレートバインディングを適用する

アプリ実行 ソースコード App.xaml <Application x:Class="HelloWorld.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> </Application> MainWindow.xaml

ボタンにリッチなテンプレートを適用する

アプリ実行 ソースコード App.xaml <Application x:Class="HelloWorld.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="Button.xaml"> </Application> Button.xaml

ボタンクリックでテンプレートを適用する

アプリ実行 起動 ボタンクリック ソースコード App.xaml <Application x:Class="HelloWorld.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="Page1.xaml"> </Application> Page1.xaml

ボタンにコントロールテンプレートを適用する

アプリ実行 ソースコード App.xaml <Application x:Class="HelloWorld.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> </Application> MainWindow.xaml

特定のページをジャーナルから削除する

アプリ実行 ※「進む」ボタンをクリックする。 検証 項目 結果 血液型入力ページがジャーナルから削除されていること OK ソースコード Human.cs namespace HelloWorld { public class Human { public string BloodType { get; set; } } } App.xaml

ページを遷移する前に検証する

アプリ実行 名前が入力されたときだけ次のページに受け渡します。 Page1.xaml Hello.xaml 検証 項目 結果 名前の入力がないとき「続行」をクリックしても遷移しない OK 名前の入力があるとき遷移する OK 遷移すると「戻る」ボタンが有効になる OK 「戻る」ボ…

プロパティを使用してページ間で状態を受け渡す

アプリ実行 Helloクラスのプロパティを使用して、入力された名前を次のページに受け渡します。 Page1.xaml BloodType.xaml ソースコード App.xaml <Application x:Class="Hello.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="Page1.xaml"> </Application> Human.cs namespa…

Application.Propertiesを使用してページ間で状態を受け渡す

アプリ実行 Application.Propertiesを使用して、入力された名前を次のページに受け渡します。 Page1.xaml BloodType.xaml ソースコード App.xaml <Application x:Class="HelloWorld.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="Page1.xaml"> </Application> Pag…

ナビゲーションとページ(マークアップその2)

前回(以下のエントリー)と同じ機能をNavigationWindowの定義を省略して実装します。 ナビゲーションとページ(マークアップ) - プログラマーな日々前回と同じ機能をマークアップで実装します。 ... App.xaml App.xamlだけが変わります。

ナビゲーションとページ(マークアップ)

前回(以下のエントリー)と同じ機能をマークアップで実装します。 ナビゲーションとページ(ビハインドコード) - プログラマーな日々今回はマークアップを使わずにビハインドコードでナビゲーションを実装します。 ... App.xaml

ナビゲーションとページ(ビハインドコード)

今回はマークアップを使わずにビハインドコードでナビゲーションを実装します。 App.xaml <Application x:Class="HelloWorld.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> </Application> App.xaml.cs using System.Windows; namespace HelloWorld { public partial class …

ユーザーコントロールを作成する

UserControl1.xaml

ウィンドウを管理する

MainWindow.xaml <Window x:Class="HelloWorld.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Width="200" SizeToContent="Height"> <Grid> <StackPanel> <Button Click="NewWindowCliecked">New Window Cli…</button></stackpanel></grid></window>

Application.ShutdownModeを検証する

App.xaml 以下のマークアップのShutdownModeを変更して検証しました。 <Application x:Class="HelloWorld.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml" ShutdownMode="OnLastWindowClose"> </Application> 検証 ShutdownModeの値 結…

WPFエントリのまとめ

WPF関連のエントリをこのページにまとめます。エントリするたびに随時更新します。 Hello World WPFをはじめました - プログラマーな日々エディタだけでWPFのHello World - プログラマーな日々ソースコードとプロジェクトファイルを手書きしてHello Worldを…