My code is here:
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using FFImageLoading.Svg.Forms;
using Xamarin.Forms;
using Xamarin.Forms.Markup;
namespace Templates
{
public partial class ABC : Grid
{
public ABC()
{
var SVG = new SvgCachedImage()
{
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
}
.Bind(SvgCachedImage.SourceProperty, nameof(IconSource), source: this);
In 4.8 I was able to do this:
.Bind(SvgCachedImage.SourceProperty, nameof(IconSource), source: this);
But now in 5.0 pre 4 it's telling me that Xamarin.Forms.Markup no longer exists and .Bind no longer works.
Does anyone know if there's a solution for this in 5.0?
Lately c# Markup for Xamarin.Forms has been moved to Xamarin.CommunityToolkit.Markup package, thus you need to:
Install that package in your project.
Reference that package in your class using using Xamarin.CommunityToolkit.Markup (also remove the old using Xamarin.Forms.Markup;)
if you read the release notes you'll see
"Remove markup extensions" (#12730)
and the linked Github issue says
Markup extensions are being moved to the Xamarin Community Toolkit
Related
I Have followed the blog https://devblogs.microsoft.com/xamarin/uiwebview-deprecation-xamarin-forms/ to remove the UIWebView dependency in my project.
According to the document
1)xamarin.forms version is 4.6
2)xamarin.ios version is 13.20
3)I added the command in mtouch Arguments and linker is link All
I still got warning while upoading build to test flight
I then followed this document https://learn.microsoft.com/en-us/xamarin/ios/release-notes/13/13.16#help-with-uiwebview-deprecation where we can find out whether UIWebView is still being used in our application.I am getting below in the build output.
MTOUCH : warning MT1502: One or more reference(s) to type 'UIKit.UIWebView' already exists inside 'Xamarin.Forms.Platform.iOS, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' before linking
I am not sure why there is reference in Xamarin.Forms.Platform.iOS as xamarin package is updated to 4.6 as per the blog.
Can anyone please help me to get rid of this warning?
Please follow this link
simply go to your iOS project, open the project properties and add this flag in the
'additional mtouch arguments field: --optimize=experimental-xforms-product-type' in your
Use WKWebView instead of UIWebView. UIWebView has been deprecated and Now The App Store will no longer accept new apps using UIWebView as of April 2020.
using System.IO;
using CustomRenderer;
using CustomRenderer.iOS;
using Foundation;
using UIKit;
using WebKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(CustomWebView), typeof(WebViewRender_iOS))]
namespace CustomRenderer.iOS
{
public class WebViewRender_iOS : WkWebViewRenderer
{
WKUserContentController userController;
protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (e.OldElement != null)
{
userController.RemoveAllUserScripts();
userController.RemoveScriptMessageHandler("invokeAction");
CustomWebView hybridWebView = e.OldElement as CustomWebView;
hybridWebView.Cleanup();
}
if (e.NewElement != null)
{
CustomWebView hybridWebView = e.NewElement as CustomWebView;
LoadRequest(new NSUrlRequest(new NSUrl(hybridWebView._WebURI)));
}
}
}
}
There are a few different changes that need to be made for the deprecation warning to go away.
The build configuration used to upload to the store (Release|iPhone, App Store|iPhone, etc.) in iOS Build section needs the following additional mtouch arguments --optimize=experimental-xforms-product-type
The app needs to use Xamarin.Forms version >= 4.5 or >= 4.6 if using Material Visual
It also needs to be using Xamarin.iOS 13.10.0.17 or higher, which is included with Visual Studio for Mac 8.4.1 and Visual Studio 16.4.3.
Remove all references to UIWebView in the codebase
More info is included in the docs and if that doesn't resolve the issue the app may be using a third-party library with a reference to UIWebView that either needs updating to a version without it or removed altogether from the app.
Thank you all for your suggestions. Below is what worked for me.
Follow the 3 steps mentioned in
https://devblogs.microsoft.com/xamarin/uiwebview-deprecation-xamarin-forms/
Run grep -r UIWebview . on repository level. It will show the list of references in .sln and third party packages
Remove or update third party libraries. Igore bin and obj folders
For Me, I had to
1.Remove deprecated scanbot.xamarin.ios SDK and add scanbot.xamarin pkg
2.Remove hockey app SDK as it was deprecated and didn’t have any updates
3.Remove googleanalytics SDK as it wasn’t being used in the project
I am adding some more control to a win form I created that runs from a .dll
The project loaded fine, after I made some changes to the form in the form visual designer, compiled and then tried to open the form... I was fronted with this error screen.
It is complaining because it can't find the NoButtonsTabControl class.
The NoTabControl.cs class:
namespace TFG_Tools {
// Extend TabControl Class to provide a multi layer canvas with hidden tabs or buttons
public class NoButtonsTabControl : TabControl {
public NoButtonsTabControl() {
Appearance = TabAppearance.FlatButtons;
ItemSize = new Size(0, 1);
//SizeMode = TabSizeMode.Fixed;
}
protected override void WndProc(ref Message m) {
// Hide tabs by trapping the TCM_ADJUSTRECT message
if (m.Msg == 0x1328) m.Result = (IntPtr)1;
else base.WndProc(ref m);
}
}// end NoButtonsTabControl class
}
The start of the main form class looks like this...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using ENSED;
using System.Globalization;
using Win32;
using WindowsEnv;
namespace TFG_Tools {
public partial class TradePanelForm : Form {
//loaded as master
private bool isMaster = false;
public void SetAsMaster() { isMaster = true; }
...
Why has this suddenly just happened now, so frustrating. I am only intermediate with c# and visual studio. I only used it for this project to create the winform.
How do I tell the designer where this class is, so this error stops appearing?
The funny thing is, it worked fine before, with this arrangement! And if I compile the code, it works, and all the form elements are there.
It's just the designer which is dying atm.
P.S I also moved this project over from Virtual Studio 2015
Thank you.
My solution to this was weird.
close down all open windows in your project
Select the "any cpu" profile
go build->clean solution
Then build->rebuild solution
Re open your form designer
This worked for me, and hopefully will clear this mess up each time it pops up.
I have 2 profiles, a 32bit and 64bit profile so I can compile the dll to both.
Something must break in the designer when I switch to these profiles to build the project.
Hopefully this saves time for others.
while adding the android project as reference to portable project it is saying reference could not be added, it causes circular dependency, I have one view in android project and needs to be call from portable project, please help me in this regard.
It is not possible to add Android project in Portable project. If you want to get any logics from android project please refer the below steps
Create interface like this in PCL
public interface PortableInterface
{
object GetLogicFromAndroidProject();
}
Add Extend this interface in your android project like below
using System;
using Xamarin.Forms;
[assembly: Dependency(typeof(PortableInterfaceRenderer))]
namespace YourProjectName.iOS
{
public class PortableInterfaceRenderer : PortableInterface
{
public object GetLogicFromAndroidProject()
{
throw new NotImplementedException(); // here write your logic
}
}
}
Now you have to call this method in PCL project
var obj = DependencyService.Get<PortableInterface>().GetLogicFromAndroidProject();
Hope this will help
When I create a new class in a sub folder in my project, by default it uses DefaultNameSpace.SubFolder.
Anyway to make it just use the default namespace defined at the project level?
You would have to create a new template for Class. You can use the existing template and just remove the extra "fluff" on the namespace.
See this answer: How do I edit the Visual Studio templates for new C# class/interface?
The specific file to modify for your version of Visual Studio is:
C:\Program Files (x86)\Microsoft Visual Studio
14.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class\Class.cs
You may want to make a copy of that structure and give your template a different name so you don't end up breaking the default template if you ever want to go back to it.
Edit
Looking at the tokens now, I don't see one specifically for the Default Namespace, $safeprojectname$ is probably as close as you get get using tokens, or just hard code it for your specific template. This is what the template would look like:
using System;
using System.Collections.Generic;
$if$ ($targetframeworkversion$ >= 3.5)using System.Linq;
$endif$using System.Text;
$if$ ($targetframeworkversion$ >= 4.5)using System.Threading.Tasks;
$endif$
namespace $safeprojectname$
{
class $safeitemrootname$
{
}
}
You can find the predefined tokens here: https://msdn.microsoft.com/en-us/library/eehb4faa.aspx
I'm trying to upgrade some Sharepoint 2007 webparts to SP2010 using the web part projects built into Visual Studio 2010. Namely, I'm using Visual Web Part to migrate our existing controls, which make extensive use of ObjectDataSource. However, when adding an ODS to the control in the Visual Web Part project, it will not pick up objects in referenced class library projects. I was able to duplicate the problem from a clean setup as follows:
Create a new Visual Web Part
Add a new class library to the solution.
Class code is as follows:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WebPartODS
{
[System.ComponentModel.DataObject(true)]
public class TestUser
{
[System.ComponentModel.DataObjectMethod(System.ComponentModel.DataObjectMethodType.Select,false)]
public List<int> TestMethod()
{
return new List<int>();
}
}
}
Add the class library project as a reference in the Web Part project
In the VisualWebPart ascx file, add a objectdatasource in the Source view:
<asp:ObjectDataSource ID="TestOD" runat="server"></asp:ObjectDataSource>
Switch to Design view, bring up the "Configure data source" wizard. On the drop down, the class from the library project will not appear.
Is there a step that I am missing here, or is there an issue with trying to do it this way?
Ok, i got it to work. Here is where i got my answer: MSDN Forumn
I originally had a separate class for my business layer. I removed it and put my code in the ascx.cs file. Then I added the following line of code to my page load method.
ObjectDataSource1.TypeName = this.GetType().AssemblyQualifiedName;
I also removed the TypeName from the ascx page.