當(dāng)前位置:
首頁 >
关于TextBox控件字体颜色绑定
發(fā)布時(shí)間:2025/4/14
30
豆豆
生活随笔
收集整理的這篇文章主要介紹了
关于TextBox控件字体颜色绑定
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1.通過WPF綁定一個(gè)屬性,比如bool型的數(shù)據(jù)
<TextBox BorderBrush="Transparent" Text="{Binding Path=DataContent,Mode=OneWay,UpdateSourceTrigger=LostFocus}" HorizontalContentAlignment="Left"Padding="5,0,0,0"VerticalContentAlignment="Center"VerticalAlignment="Stretch" IsReadOnly="True"><TextBox.Style><Style TargetType="{x:Type TextBox}"><Style.Triggers><DataTrigger Binding="{Binding FrameColor}" Value="True"><Setter Property="Foreground" Value="Red"> </Setter></DataTrigger><DataTrigger Binding="{Binding FrameColor}" Value="False"><Setter Property="Foreground" Value="Green"></Setter></DataTrigger></Style.Triggers></Style></TextBox.Style></TextBox> View Code2.幾個(gè)注意點(diǎn)
<Style TargetType="{x:Type TextBox}">??是將風(fēng)格指向TextBox,沒有這句話,就不能繼承TextBox控件的基本風(fēng)格。
?
轉(zhuǎn)載于:https://www.cnblogs.com/jiangyan219/articles/8576868.html
總結(jié)
以上是生活随笔為你收集整理的关于TextBox控件字体颜色绑定的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java操作符自测运算符精度
- 下一篇: LuoGU 线性DP