Architect's Log

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

WPF

DataTemplateSelectorでテンプレートを選択する

アプリ実行 ソースコード App.xaml <Application x:Class="WpfApplication6.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

DataTemplateを使用してXMLをバインディングする

アプリ実行 ソースコード App.xaml <Application x:Class="WpfApplication6.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

ObservableCollectionでリストへの追加を通知する

アプリ実行 起動 入力 追加 再度追加 ソースコード 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

MVVMパターンでINotifyPropertyChangedを実装して変更が通知されるようにする

アプリ実行 起動 入力 ソースコード こちらを参照してください。INotifyPropertyChangedを実装しても変更が通知されませんINotifyPropertyChangedを実装しても変更が通知されません。どのようにすれば変更が通知されるのでしょうか? ...

XMLを動的にバインドする

データソースを動的に判断する必要がある場合は、DataContextプロパティを使用します。 アプリ実行 ソースコード 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

XMLを静的にバインドする

アプリ実行 ソースコード App.xaml <Application x:Class="WpfApplication6.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>…

データテンプレートを使用する

データテンプレートはデータ(このエントリではHuman)を受け取り、表示ツリーを構築します。 アプリ実行 起動 入力 ソースコード 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="MainWindow.xaml"> </Application> MainWindow.xaml

複雑なオブジェクトをバインディングする

アプリ実行 ソースコード App.xaml <Application x:Class="WpfApplication5.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> Main…

データテンプレートを使用する

データテンプレートはデータ(このエントリではHuman)を受け取り、表示ツリーを構築します。 アプリ実行 起動 入力 ソースコード 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="MainWindow.xaml"> </Application> MainWindow.xaml

データテンプレートを使用する

データテンプレートはデータ(このエントリではPerson)を受け取り、表示ツリーを構築します。 アプリ実行 起動 入力 ソースコード App.xaml <Application x:Class="WpfApplication6.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="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="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

FlowDocumentにコントロールをホストする

アプリ実行 ソースコード 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

FlowDocumentで段落を表示する

アプリ実行 ソースコード 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

Run要素を使用してリッチテキストを表示する

アプリ実行 ソースコード 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

Canvasのすべての要素を透明にする

アプリ実行 ソースコード 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="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