Reputation: 3139
I am having the same issue in the link below. There are no answers for this. It was asked 1 year ago
XAML textbox border goes away when changing isreadonly?
Can someone help me ? This is my Existing CSS for Textbox
<Style TargetType="TextBox" x:Key="StandardTextBox">
<Style.Resources>
<fawgCommon:ControlBackgroundConverter x:Key="BackgroundConverter" />
</Style.Resources>
<Setter Property="telerik:StyleManager.Theme" Value="{DynamicResource Theme}"/>
<Setter Property="Background">
<Setter.Value>
<MultiBinding Converter="{StaticResource BackgroundConverter}">
<Binding />
<Binding Mode="OneTime"/>
</MultiBinding>
</Setter.Value>
</Setter>
<Setter Property="Foreground" Value="{DynamicResource CurrentThemeForegroundBrush}" />
<Setter Property="CaretBrush" Value="{DynamicResource CurrentThemeForegroundBrush}" />
</Style>
Upvotes: 0
Views: 1222
Reputation: 63317
Not sure why this could be a problem, but in a basic demo you can just use some Trigger listening to IsReadOnly
and set the Border for the TextBox normally:
<TextBox IsReadOnly="True" BorderThickness="1">
<TextBox.Style>
<Style TargetType="TextBox">
<Style.Triggers>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="BorderBrush" Value="Blue"/>
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
The above example sets the IsReadOnly
to true
initially, so some Blue border will be shown.
Update:
for the code you posted, it should be like this:
<Style TargetType="TextBox" x:Key="StandardTextBox">
<Style.Resources>
<fawgCommon:ControlBackgroundConverter x:Key="BackgroundConverter" />
</Style.Resources>
<Style.Triggers>
<Trigger Property="IsReadOnly" Value="True">
<Setter Property="BorderBrush" Value="Blue"/>
<Setter Property="BorderThickness" Value="1"/>
</Trigger>
</Style.Triggers>
<Setter Property="telerik:StyleManager.Theme" Value="{DynamicResource Theme}"/>
<Setter Property="Background">
<Setter.Value>
<MultiBinding Converter="{StaticResource BackgroundConverter}">
<Binding />
<Binding Mode="OneTime"/>
</MultiBinding>
</Setter.Value>
</Setter>
<Setter Property="Foreground"
Value="{DynamicResource CurrentThemeForegroundBrush}" />
<Setter Property="CaretBrush"
Value="{DynamicResource CurrentThemeForegroundBrush}" />
</Style>
Upvotes: 1