Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Problem Occuring when access User controls
4 replies. Latest Post by ccoombs on September 20, 2008.
(0)
simbuaar...
Participant
1172 points
405 Posts
09-19-2008 6:10 AM |
Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin-top:0in; mso-para-margin-right:0in; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0in; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}
Hi In my silver light application I am using only two pages there are
Page, page 2 Here my code
Page
<UserControl x:Class="SilverlightApplication1.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Canvas x:Name="LayoutRoot" Background="White">
<Canvas Height="106" Width="157" Canvas.Left="184" Canvas.Top="89" x:Name="Imageplace"/>
<TextBlock Height="32" Width="104" Canvas.Left="8" Canvas.Top="212" Text="ClickHere" TextWrapping="Wrap" x:Name="Tb" MouseLeftButtonDown="Tb_MouseLeftButtonDown"/>
</Canvas>
</UserControl>
Page2
<UserControl x:Class="SilverlightApplication1.Page2"
<Image x:Name="Image1" Height="116" Width="116" Canvas.Left="136" Canvas.Top="64" Source="Img/men thick.jpeg" Stretch="Fill"/>
Now my requirement is I want to control page2 image by page Text block click event but it shouldn’t working
Page Code behind
public partial class Page : UserControl
{
public Page()
InitializeComponent();
Page2 p2 = new Page2();
Imageplace.Children.Add(p2);
}
private void Tb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
p2.Image1.Height = 5;
09-19-2008 6:11 AM |
ccoombs
Contributor
5168 points
758 Posts
09-19-2008 9:52 AM |
Come on man...
You're creating and operating on a new Page2 in your mouseleftbuttondown event. You have to talk to the instance you add to Imageplace in your constructor.
09-20-2008 2:05 AM |
hos can i use the constructor there
09-20-2008 8:49 AM |
public partial class Page : UserControl { private Page2 p2; public Page() { InitializeComponent(); p2 = new Page2(); Imageplace.Children.Add(p2); } private void Tb_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { p2.Image1.Height = 5; } }