Wpf XAML文本框边框,可随时使用

Wpf XAML文本框边框,可随时使用,wpf,xaml,Wpf,Xaml,我有同样的问题在下面的链接。对此没有答案。这是一年前问的 有人能帮我吗?这是我现有的文本框CSS <Style TargetType="TextBox" x:Key="StandardTextBox"> <Style.Resources> <fawgCommon:ControlBackgroundConverter x:Key="BackgroundConverter" /> </Style.Resources>

我有同样的问题在下面的链接。对此没有答案。这是一年前问的

有人能帮我吗?这是我现有的文本框CSS

<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>

不确定为什么会出现问题,但在基本演示中,您可以使用一些触发器侦听
IsReadOnly
并正常设置文本框的边框:

<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>

如果问题相同,那么您需要正确标记您的问题,
WPF
tag不适用于WinPhone问题。我在上面添加了我的代码。你能帮我修改一下上面的代码吗?我自己也试过。它不起作用。但有趣的是,若我点击文本框,边框就会出现,若我点击另一个文本框,边框就会出现disappearing@WPFRookie我也尝试了代码第一,它几乎工作。当鼠标位于文本框上方时,边框将稍微淡出(可能是默认动画造成的)。我无法重现你描述的行为。你的文本框只是一个标准文本框,没有任何其他代码(除了你发布的内容)吗?是的,它的标准文本框没有任何其他代码
<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>