Evo XAML
Code:
<UserControl x:Class="Silverlight_GO.Page"
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<Canvas x:Name="imCan" >
<TextBox x:Name="tb1" Height="20" Width="100"/>
<TextBlock Height="20" Width="100" Text="OK" Canvas.Left="0" Canvas.Top="20" MouseLeftButtonDown="TextBlock_MouseLeftButtonDown"/>
</Canvas>
</Grid>
</UserControl>
<UserControl x:Class="Silverlight_GO.Page"
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<Canvas x:Name="imCan" >
<TextBox x:Name="tb1" Height="20" Width="100"/>
<TextBlock Height="20" Width="100" Text="OK" Canvas.Left="0" Canvas.Top="20" MouseLeftButtonDown="TextBlock_MouseLeftButtonDown"/>
</Canvas>
</Grid>
</UserControl>
Evo i metode TextBlock_MouseLeftButtonDown koja bi trebala dodat image
Code:
namespace Silverlight_GO
{
public partial class Page : UserControl
{
public Page ()
{
InitializeComponent ();
}
private void TextBlock_MouseLeftButtonDown ( object sender, MouseButtonEventArgs e )
{
( sender as TextBlock ).Text = "bLA";//ovo je samo primjer da metoda radi ali image se ne dodaje
Image myImage = new Image ();
myImage.Source = new BitmapImage ( new Uri ( "buche_red_color_go.jpg", UriKind.Relative ) );
imCan.Children.Add ( myImage );
}
}
}
namespace Silverlight_GO
{
public partial class Page : UserControl
{
public Page ()
{
InitializeComponent ();
}
private void TextBlock_MouseLeftButtonDown ( object sender, MouseButtonEventArgs e )
{
( sender as TextBlock ).Text = "bLA";//ovo je samo primjer da metoda radi ali image se ne dodaje
Image myImage = new Image ();
myImage.Source = new BitmapImage ( new Uri ( "buche_red_color_go.jpg", UriKind.Relative ) );
imCan.Children.Add ( myImage );
}
}
}