1
は私が私のTextBox
のスタイルを設定するには、このDynamic Resource
ていたときにTextBoxのスタイルはデフォルト設定のまま:WPF - トリガー火
<Style x:Key="TextBoxStyle" TargetType="TextBox">
<Setter Property="FontSize" Value="30"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="BorderThickness" Value="2"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="FontFamily" Value="CenturyGothicRegual"/>
<Setter Property="Foreground" Value="#FF5B5B5B"/>
<Setter Property="Opacity" Value="1"/>
<Setter Property="BorderBrush" Value="#FF5B5B5B"/>
<!--<Setter Property="FocusVisualStyle">
<Setter.Value>
<Style x:Name="ActiveStyle" TargetType="{x:Type TextBox}">
<Setter Property="BorderBrush" Value="Black"/>
</Style>
</Setter.Value>
</Setter>-->
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="BorderThickness" Value="10"/>
</Trigger>
<Trigger Property="IsFocused" Value="True">
<Setter Property="BorderBrush" Value="Pink" />
<Setter Property="BorderThickness" Value="15"/>
</Trigger>
</Style.Triggers>
</Style>
そして、それを使用してテキストボックス:
<TextBox Grid.Row="2" Grid.Column="1" Margin="2,2,2,2" Style="{DynamicResource TextBoxStyle}"
FontSize="30" Text="asdasd" HorizontalContentAlignment="Left" VerticalContentAlignment="Center"
FocusVisualStyle="{StaticResource TextBoxStyle}">
</TextBox>
を再び問題がありますマウスの上にマウスを置いたり、テキストボックスをクリックすると、境界線がデフォルトの青色になります。 しかし、境界厚さはになります(醜いですが、デバッグするのには醜いです)。だからこの問題を回避する方法は?
それは一種の作品は、今とき、私 ** PresentationFramework.dllで 'System.InvalidOperationException'タイプの例外が発生しましたが、ユーザコードで処理されませんでした。 追加情報: "{DependencyProperty.UnsetValue}"は"BorderBrush"プロパティの場合は無効な値です。 この例外のハンドラがある場合、プログラムは安全に継続することができます。** – agiro
最初は例外を翻訳するのを忘れました申し訳ありません。私は今編集していた、それは部分的に英語だった。 – agiro
これは 'BorderBrush'セッターを持っています、それはテンプレートの直前です。 ' 'これが行です。 何か不足していますか? –
agiro