参照
WPF – 文字の縁取り方法 – astel-labs.net
WPF – 文字の縁取りをする – astel-labs.net
ListViewの中身の幅をいっぱいに広げる
MainWindow.xaml
<Window x:Class="WpfApp15.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp15"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="400">
<Grid>
<ListView Margin="30" ItemsSource="{Binding arrayString}">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
</Style>
</ListView.ItemContainerStyle>
<ListView.ItemTemplate>
<DataTemplate>
<Button Height="50" Content="{Binding}"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Window>
await/async等の別スレッドからコントロールのプロパティを変更する(2)
前回の await/async等の別スレッドからコントロールのプロパティを変更する
Application.Current.Dispatcher.Invoke(() =>
{
});
await Application.Current.Dispatcher.InvokeAsync(() =>
{
});
C#でJsonを扱う DynamicJson編
・C#でJsonを扱う DynamicJson編
・C#でJsonを扱う Json.Net JToken/JObject/JArray編
・C#でJsonを扱う Json.Net DeserializeObject編
・C#でJsonを扱う System.Text.Json編
DynamicJsonについて
アプリケーションにフォントを埋め込む
今回お借りしたフォント
源真ゴシック (げんしんゴシック) | 自家製フォント工房
プロジェクト
Fontフォルダを作成し、フォントファイルを格納
ビルドアクションはResource
(例としてFontフォルダにしている 他のフォルダ名でもOK)


TextBoxのBindPropertyを即時反映させる
UpdateSourceTrigger=PropertyChanged を付けることで、入力後即時反映される。
<TextBox Text="{Binding Url, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="TextChanged">
<l:LivetCallMethodAction MethodTarget="{Binding}" MethodName="OnURLChanged" />
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
MahAppsDialogの表示
MainView.xaml
<Controls:MetroWindow
x:Class="WpfApp12.View.MainView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp12.View"
mc:Ignorable="d"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:ei="http://schemas.microsoft.com/xaml/behaviors"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:l="http://schemas.livet-mvvm.net/2011/wpf"
xmlns:vm="clr-namespace:WpfApp12.ViewModel"
xmlns:Dialog="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
Dialog:DialogParticipation.Register="{Binding}"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
TextElement.FontSize="13"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{DynamicResource MaterialDesignFont}"
ResizeMode="CanResizeWithGrip"
WindowStartupLocation="CenterScreen"
GlowBrush="{DynamicResource AccentColorBrush}"
WindowTransitionsEnabled="False"
TitleCharacterCasing="Normal"
ShowIconOnTitleBar="True"
Title="MainView" Height="450" Width="800">
<Window.DataContext>
<vm:MainViewModel>
<vm:MainViewModel.MahAppsDialogCoordinator>
<Dialog:DialogCoordinator/>
</vm:MainViewModel.MahAppsDialogCoordinator>
</vm:MainViewModel>
</Window.DataContext>
<Grid>
<Button Content="MessageBox" Margin="10,10,657,359" Height="Auto">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<l:LivetCallMethodAction MethodTarget="{Binding}" MethodName="ShowMessageBox" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button Content="Progress" Margin="155,10,512,359" Height="Auto">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<l:LivetCallMethodAction MethodTarget="{Binding}" MethodName="ShowProgress" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</Grid>
</Controls:MetroWindow>
[VisualStudio2019]BlendSDKからMicrosoft.Xaml.Behaviors.Wpfへ移行
VisualStudio2019から、BlendSDKが提供されなくなった為、
Microsoft.Xaml.Behaviors.Wpfへ移行する必要がある。
BlendSDK
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
Microsoft.Xaml.Behaviors.Wpf
xmlns:ei="http://schemas.microsoft.com/xaml/behaviors"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
[Livet]非アクティブ時におけるWindowInteractionMessageActionの注意点
Livetを用いてViewModelからViewを操作する為に
WindowInteractionMessageActionを用いる際、
デフォルトのままだとWindowが非アクティブの状態では
正しくメッセージが送信されない(実行されない)。
例として、
OnContentRendered→最小化(非アクティブ化)→3秒待つ→最大化 を行う場合は、
下記のように InvokeActionOnlyWhenWindowIsActive="False" を指定する。