Skip to main content

Microsoft Silverlight

Answered Question Problem Occuring when access User controls RSS Feed

(0)

simbuaarumugam
simbuaar...

Participant

Participant

1172 points

405 Posts

Problem Occuring when access User controls

  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"

    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">

      <Image x:Name="Image1" Height="116" Width="116" Canvas.Left="136" Canvas.Top="64" Source="Img/men thick.jpeg" Stretch="Fill"/>

 

    </Canvas>

</UserControl>

 

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)

        {

            Page2 p2 = new Page2();

            p2.Image1.Height = 5;          

        }  

 }

 

SimbuAarumugam India
http://simbusoftwareengineer.blogspot.com
(Mark As Answer If its Satisfy your needs)

simbuaarumugam
simbuaar...

Participant

Participant

1172 points

405 Posts

Re: Problem Occuring when access User controls

  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"

    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">

      <Image x:Name="Image1" Height="116" Width="116" Canvas.Left="136" Canvas.Top="64" Source="Img/men thick.jpeg" Stretch="Fill"/>

 

    </Canvas>

</UserControl>

 

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)

        {

            Page2 p2 = new Page2();

            p2.Image1.Height = 5;          

        }  

 }

 

SimbuAarumugam India
http://simbusoftwareengineer.blogspot.com
(Mark As Answer If its Satisfy your needs)

ccoombs
ccoombs

Contributor

Contributor

5168 points

758 Posts

Re: Problem Occuring when access User controls

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.

simbuaarumugam
simbuaar...

Participant

Participant

1172 points

405 Posts

Re: Re: Problem Occuring when access User controls

hos can i use the constructor there

SimbuAarumugam India
http://simbusoftwareengineer.blogspot.com
(Mark As Answer If its Satisfy your needs)

ccoombs
ccoombs

Contributor

Contributor

5168 points

758 Posts

Answered Question

Re: Re: Problem Occuring when access User controls

  

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;
        }
 }
 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities