Just started writing on WPF. In the course I showed such a problem: it is necessary to display text on the Image component, which will change as the program progresses. How can this be realized? In Google I found only some options with TextBlock in a xaml file.

    1 answer 1

    Very correct options you found in google.

    <Grid> <Image Source="..."/> <TextBlock Text="{Binding YourText}"/> </Grid> 

    Or were you going to patch a picture on the fly?

    • I have an Image array in my program, I specify the source of the image in the C # code ImageSourceConverter imgs = new ImageSourceConverter (); this.Card.SetValue (Image.SourceProperty, imgs.ConvertFromString ("CardOpen.png")); can be about the same way and push the text there? Until a certain point I don’t know what the text will be there, but each Image is different. - Pavel Voevoda
    • one
      You write as on WinForms. Master MVVM and do it through Binding. Manually set the attributes of the elements - 19th century. - VladD
    • I had previously written only on WinForms, so I switch to WPF, but so far this technology is not very clear - Pavel Voevoda
    • Read about Binding, DependencyProperty and ViewModel, it will immediately become easier to write on WPF, and it will immediately become clear than this is better than WinForms. Fair. If you have to manipulate the controls in the code, most likely you are doing something wrong. Everything (almost everything) should be in XAML. - VladD