Bonjour, j'ai un Textblock qui contient un certain nombre de mots et un code qui recherche un mot précis ici par exemple "that".
Je souhaiterais que si le mot est trouvé il se mette en rouge.
<StackPanel Margin="20">
<TextBlock FontFamily="Verdana"
Name="TB1"
FontSize="28"
LineStackingStrategy="MaxHeight"
LineHeight="10"
Width="500"
TextWrapping="Wrap" >
Use the <Run FontSize="30">LineStackingStrategy</Run> property to determine how a line box is
created for each line. A value of <Run FontSize="20">MaxHeight</Run> specifies that the stack
height is the smallest value that contains all the inline elements on that line when those
elements are properly aligned. A value of <Run FontSize="20">BlockLineHeight</Run> specifies
that the stack height is determined by the block element LineHeight property value.
</TextBlock>
<StackPanel Margin="0,20,0,0" HorizontalAlignment="Center">
<Line Stroke="Green" X2="500" />
</StackPanel>
</StackPanel>
public MainPage()
{
this.InitializeComponent();
string zonetext = TB1.Text;
string mot = "that";
if (zonetext.Contains(mot)==true)
{
// mot.Foreground=Brushes.Red;
}
}
JF Collombet ® CreateSpecificCulture