I'm trying out the Hello World tutorial in the MonoTouch Trial version and I have put in all the code and attempted a build.
In the designer.cs file, the line
partial void actBtn (MonoTouch.Foundation.NSObject sender)
gives an error of
A partial method 'HelloWorld_iPhone.HelloWorld_iPhoneViewController.actBtn (MonoTouch.Foundation.NSObject sender)' implementation is missing a partial method declaration.
What did I miss?
I should add that this line was inserted automatically by MonoTouch - I only wrote the single line of method code which follows.
I have never tried monotouch but one think ticks here ->
Looking at the code in question, can we have a partial method in c# and monotouch??
I have used partial class but we cannot declare a partial method.
partial cannot be used as a access modified for methods.
The way the tutorial reads, it implies that you put the code in the Designer.cs file. That's wrong. The code they are showing you actually goes in the Controller.cs file.
Here's what you add to the Controller.cs file:
partial void actnButtonClick (MonoTouch.Foundation.NSObject sender)
{
this.lblOutput.Text = "Action button " + ((UIButton)sender).CurrentTitle + " clicked.";
}
I could achieve it by putting the statement in the file controller.cs.
In my example this way:
partial void action1 (MonoTouch.Foundation.NSObject sender);
and in my designer.css:
[Action ("action1:")]
partial void action1 (MonoTouch.Foundation.NSObject sender){
this.lblOutput.Text=" Action 1 activated";
}
which means that the statement is in a separate class, and implementation in the designer.
Related
I am trying to inherit from a base page instead of Normal Page control of XAML but Visual Studio is giving me compile time errors that OnNavigatedTo method not found to be overridden.
I am doing this because I have multiple pages with a lot of similar code and I want to write that code just once, so I want to write that code in parent class and then inherit all pages from that parent class, I followed guidelines as stated on multiple resources on internet and below is my code.
Parent Class:
public class VideoParentPage : Page
{
}
Child Class (AllVideoPage.xaml.cs):
public sealed partial class AllVideosPage : VideoParentPage
{
public AllVideosPage() : base()
{
InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
SetBanner();
}
}
XAML in file AllVideosPage.xaml:
<local:VideoParentPage
xmlns:local="using:Fluent_Video_Player.Views.Shared"
...some unrelated XAML code...
</local:VideoParentPage>
Note: I have used all necessary using statement in C# classes.
You should try cleaning the solution Build > Clean Solution, closing VS, removing the remaining bin and obj folders and then compiling the app again.
I'm trying to break up a very big VSTO IRibbonExtensibility class into multiple smaller classes to make things more manageable.
I tried creating a partial class with all my Visibility callbacks in it.
The code compiles fine but doesn't work in MS Word.
Error: The call to GetCustomUI() for RibbonID 'Microsoft.Word.Document' failed.
Any idea why this isn't working??
[ComVisible(true)]
public partial class Ribbon : O.IRibbonExtensibility
{
..
}
public partial class Ribbon
{
..
}
Sorry, my bad..
I had moved the Ribbon.xml file into a new folder and that caused the issue
I have actually tried to fix this.
Basically i cannot start my project anymore with the error
Error 1 Missing partial modifier on declaration of type 'SystemTools.Controls.User.SideBar'; another partial declaration of this type exists
[PathRemovedManually]obj\Debug\Controls\User\SideBar.g.cs 41 18 SystemTools
I have attempted to change the code in this file to
public partial class SideBar : System.Windows.Controls.UserControl, System.Windows.Markup.IComponentConnector {
Howevever everytime i rebuild it reverts back to
public class SideBar : System.Windows.Controls.UserControl, System.Windows.Markup.IComponentConnector {
I have also deleted my entire debug folder and still having issues.
Can someone give me any ideas ?
SideBar.g.cs is autogenerated dont edit that file manually. Try to check your XAML declaration for SideBar control. And yes, as response to your comment those craps have meaning and commonly are required.
I have a Form called EmployeeForm inside this form i'm including some UserControl and when I edit EmployeeForm every UserControl inside the form are lost.
This picture show a diff between TFS(left) and Local(right) file, after modifying the name of a combobox
Example of this.ucEmployeeKeyOne :
public partial class Employee_EmployeeKeyOneRelationUC
: Employee_EmployeeKeyOneRelation_GenericUC
{ [other Code Here] }
public class Employee_EmployeeKeyOneRelation_GenericUC
: RelationUC<MyObject>
{ }
and the definition of RelationUC :
public partial class RelationUC<T>
: DataUserControlBase
{ [other Code Here] }
public partial class DataUserControlBase
: UserControlBase
{ [other Code Here] }
public partial class UserControlBase
: System.Windows.Forms.UserControl, MyInterfaceHere
{ [other Code Here] }
All UserControl i'm losing are inherited from RelationUC<T>. Does the generic type of RelationUC may cause the problem?
For the Vs designer to load the controls, the control should be able to initialize including all public properties and you must have a empty constructor. If you don't have an empty constructor or have properties that are returning from the inherited nullable class, it is most likely the the designer will crash.
To Debug this,
1) open you project in VS but do not open the file that contains the controls yet;
2) open another VS and attach the process of VS that your project is opened;
3) set the break on exceptions (short cut 'CTRL + D, CTRL +E' ) to all (once you become familiar with what exception the designer is throwing, you can set that exception only.);
4) Go to the VS with you project and open the file that contain your user control. when the exception is thrown, the second VS will catch it and tell you exactly why and where.
When I'm developing a ConsoleApp there is no problem to use classes in my Main that I've created in separated files (Project Menu --> Add Class). But later, when I try to do it in WPF that class is not recognized. I have made sure that the namespace it's the same both in my "MainWindow.xaml.cs" and my Class Canal.cs. When I define that same class but inside MainWindow.xaml.cs everything works fine, but due to the extension of the code I prefer separate it.
MainWindow.xaml.cs:
//using
namespace Tcomp
{
public partial class MainWindow : Window
{
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{ //Stuff but I can't use class created outside of MainWindow.xaml.cs
}
}
}
Canal.cs
//using
namespace TComp
{
public class Canal
{ //some propreties here
}
}
Thanks.
Create the class inside a library project not on a console app. And on your WPF project, add a project reference to the library project you have created.
#mcxiand already answered your question. I would like to add another option: you can use a
public partial class MainWindow : Window
and add it to as many files as you want containing your code, thus there will be no need to create additional class library. The key word here is partial, which allows the code encapsulated in this class to spread over multiple files (.cs).
You must either instantiate the Canal class:
var myClass = new Canal();
and then you can use the properties from it. Make myClass a private member of your MainWindow.xaml.cs and you can access it anytime. Or the second way, make Canal class static and then you can access it from everywhere. Hope this helps.