マウスオーバー時に境界線が表示されるテキストブロックのカスタムコントロールを作成しようとしています。私はWPFの初心者ですが、非常にシンプルなカスタムコントロールを作成しています。私はこれをXAML UserControlに実装する必要があります。マウスオーバー境界線をテキストブロック用のカスタムコントロール
ご意見をいただければ幸いです。再度ありがとう、StackOverflow。
編集:永続性プロパティを複数の異なるコントロールにバインドする必要があるため、カスタムコントロールでこれを行う必要があります。これは私が持っているものであり、それが動作していません。
xmlns:customControls="clr-namespace:****.CustomControls"
....
<customControls:MouseOverBorder>
<TextBlock Style="{StaticResource ResourceKey=HomePageButtonText}"
Height="100"
Width="100"
Margin="5"
Text="View Reports" />
</customControls:MouseOverBorder>
そしてユーザーコントロール:
<UserControl
x:Class="****.MouseOverBorder"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d">
<UserControl.Resources>
<ResourceDictionary>
<Style x:Key="MouseOverBorder" TargetType="{x:Type Border}">
<Setter Property="BorderThickness" Value="1" />
<Setter Property="CornerRadius" Value="3" />
<Style.Triggers>
<Trigger Property="Border.IsMouseOver" Value="true">
<Setter Property="BorderBrush" Value="White" />
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
</UserControl.Resources>
<Border Style="{DynamicResource MouseOverBorder}" BorderThickness="1" CornerRadius="3" SnapsToDevicePixels="True"/>
はIsMouseOver' ''ためTrigger'で 'Style'を作成します。 (これはカスタムコントロール、btwを必要としません) –