When i try to use a method Add_button_external();, which is outside the class MyButton, there is no problem.
The code behind file for user control looks like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace PhoneApp4
{
public partial class WindowsPhoneControl1 : UserControl
{
public WindowsPhoneControl1()
{
InitializeComponent();
// THIS WORKS FINE
LayoutRoot.Children.Add(Add_button_external("button name"));
// THIS DOESNT WORK :(/>
MyButton t = new MyButton();
t.Add_button_internal("button name");
}
public Button Add_button_external(string m)
{
Button btn = new Button();
btn.Content = m;
return btn;
}
public class MyButton
{
public MyButton() { }
public Button Add_button_internal(string n)
{
Button btn = new Button();
btn.Content = n;
return btn;
}
}
}
}
Can you please help me to solve my problem? Thank you in advance.

New Topic/Question
Reply


MultiQuote


|