Click here to Skip to main content
15,891,762 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Is it possible to insert a text block into an image on runtime? If it is, Kindly share the code
Posted

1 solution

Yes, you can place a text block over an image. Consider the following
XAML
HTML
<window x:class="MyProject.MainWindow" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <grid name="mygrid">

    </grid>
</window>

C#
C#
public partial class MainWindow : Window {
   public MainWindow() {
      InitializeComponent();

      mygrid.Children.Add(
         new System.Windows.Controls.Frame() {
            Background = Brushes.Tomato });
      mygrid.Children.Add(
         new System.Windows.Controls.TextBlock() {
            Text = "Here goes my text",
            Margin = new Thickness(50, 50, 0, 0) });
   }
}
 
Share this answer
 
v2
Comments
Member 11521909 25-Jul-15 3:00am    
Thank You!!
Wendelius 25-Jul-15 3:03am    
You're welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900