I've found a nice VB.NET Theme online, however, my application was C#, so I did the most logical thing, which is creating a new VB.NET Class Library, using the theme class, and then using the DLL through my toolbox's items.
This is the theme's code: http://pastebin.com/bxM7wtyN.
Note that the classes were not set to public, but I did so, as I thought that's why the error popped up. This is the error I'm getting.
Why's that, exactly? I think everything looks fine, and the theme's code works for everyone as they're using VB.NET, but not for me.
Uh, You have 2 ways. Find a c# version or try to convert into c# from vb.net.
Try adding the code to a blank file in your project, and then build the project but don't run it. Now in Visual Studio, open the Toolbox and the new controls should be at the top.
Related
For a Xamarin Forms application, I have been using a solution to track touch using code from an example out of Microsoft's Xamarin Forms Sample Project, specifically the Touch Tracking Effect sample.
I took that sample and simplified it down to just directly starting up with the BoxViewDraggingPage.xaml from App.xaml.cs and removing all other XAML files. That compiled and ran fine.
I then created a .NET Maui App with the same BoxViewDraggingPage (and the same TouchActionEventArgs.cs, TouchActionEventHandler.cs, TouchActionType.cs, and TouchEffect.cs) as was in the Xamarin Forms version.
I added the same TouchEffect.cs files that were in the sample for the specific platforms (iOS also has a TouchRecognizer.cs file)
When running it at that point I got the following:
So then I tried following the instructions for Migrating Xamarin.Forms Effects. The explanation for how Xamarin.Forms effects were set up matched perfectly, but it was unclear to me from that page what class the section titled "Effects in .NET MAUI" was replacing since it had a different class name than the previous code snippets earlier in the article. It seemed like it is replacing the FocusEvent class in the shared platform code and then specifies the platform specific code within #if platform sections (#if WINDOWS, #if __ ANDROID __, etc.) and so I am guessing that means the TouchEffect.cs files are no longer needed in the platform specific folders.
I didn't have a chance to find out if that was the case or if it works, because when I try to compile, I get:
I don't find any missing Nuget packages or assemblies when I tried searching. If I click the dot after Platform, I get the following choices, with instructions to use the navigation bar to switch contexts:
But I am already targeting net6.0-windows10.0.19041.0:
so I'm not sure why it says Not Available for that.
So, I am stuck trying to get this to work.
I am looking either for a solution to get the sample code working as it is in the Xamarin.Forms project, but for .NET MAUI (whether that be set up how the sample originally had it or how it is described in the Migrating Xamarin.Forms Effects link) - it could be that I am missing something simple in how to get that Microsoft.Maui.Controls.Compatibility.Platform.UWP piece to compile.
Or, the other possibility is that same link says that .NET MAUI Handlers can also handle this type of scenario. So if someone can show all the pieces that would need to be modified in order to do the same solution but using .NET MAUI Handlers, I am open to that. But it seems that the easiest path, though, should be to get the Effects working in .NET MAUI since everything is already written that way. I am just leaving both options open in looking for a solution.
EDIT:
OK, I figured out why the UWP portion had red squiggles under it. I figured out what "using the navigation bar to switch contexts" in the above screenshot meant. It meant I needed to select the context in the dropdown pictured below:
However, this just moves the squiggles to PlatformEffect and I cannot figure out what to do with the context or anything else to resolve that:
OK, I found out that PlatformEffect now inherits from Microsoft.Maui.Controls.PlatformEffect instead of the separate Platform inheritances shown in the Migrating Xamarin.Forms Effects example. That example is out of date and I didn't realize that and so it was confusing me.
I recently tried to make a WPF application with Visual Studio 2013 (compiling against .NET 4.5) . I wanted to draw something on a canvas. But the method doesn't work.
private void drawSomething(Graphics g)
I took some old code I used with Windows Forms when I noticed that my Graphics wasn't found anymore. First I thought I forgot the using directive but I used
using System.Drawing;
Still Graphics couldn't be found. I was reading on the web that some people had to add a reference to the project. I did this and added the reference manually. Still it doesn't work.
So I start wondering. Has this changed? Haven't used C# for a while.
Hopefully someone knows what to do.
In visual Studio, you can right click on Graphics and then choose the option named 'Resolve' The IDE will list you available assemblies for you to import one of them.
If you can't see the RESOLVE option, figure you need to add a manual reference to your project...
Hey! I was looking at a cool layout example in particular the V3FluidLayout.xaml found inside this set of examples : http://gallery.expression.microsoft.com/en-us/DynamicLayoutTrans
Anyhow - this appears to be a silverlight app - it runs within a browser. I am trying to pull the V3FluidLayout example into a WPF app - and struggling.
I "add an existing item" pulling the .xaml file into my project. When it goes to compile it, the following errors are found :
Are these artifacts Silverlight? The following is the xaml code within the V3FluidLayout.xaml file
http://pastebin.com/h9ujUax6
Can anybody help me pin why this is not working - and how I can convert that xaml code to work inside my wpf app.
Thanks
Andy
Basically (and from only a quick glance), you'll need a reference to the WPF versions of System.Windows.Interactivity and Microsoft.Expression.Interactions - they are part of Blend. Actually look at the references of that project and find the exact same references, only for WPF.
It looks like they contain pretty much the same classes for both WPF and Silverlight, so I think it should work in the end.
Add references to the interactivity assemblies found here:
C:\Program Files (x86)\Microsoft SDKs\Expression\Blend.NETFramework\v4.0\Libraries
You need to install the Blend SDK to get them, the come with Blend also.
It is possible to create an instance of a C# class within a aspx.vb codebehind file?
When I try this within the Page_Load event:
Dim oFlow As New Flow(HttpContext.Current.Request)
I get the Type 'Flow' is not defined. The Flow class itself is located here:
App_Code/CSCode/Cust/Frm/Flow.cs
There's no namespace associated with this class.
Any suggestions would be greatly appreciated.
cheers,
devin
There seems to be a few articles on google which say that it is possible to call a C# class from VB directly using a reference. However I have never used this method before. Here is what I would suggest:
Create a new project inside of your solution
Create this project as a c# class library
Compile that project either in debug or release (this will create a .dll in the projects debug/bin or release/bin folder).
Go back to your ASP.Net VB project and make a reference (right click the project in the explorer and your should see the reference option) to the DLL you just created.
Now you can call the c# code just as you would any other class library from your VB code. Also, if you need to make changes to the C# code all you have to do is make them, compile again, and since it is referenced in your VB project everything will be updated auto-magically.
Hope this helps.
Thanks for the response.
The reason why I was having issues is because I'm using IIS 6 on my windows xp box along with the XP PRO IIS Admin Tool and I didn't have the correct site running.
Once I switched over to the proper site within the XP PRO IIS Admin Tool and then recompiled, I was able to call my C# class from within the .vb page without a hitch and intellisense recoginized the class as well :)
cheers,
devin
I am compiling and importing this multicolumncombo box class. I am able to run the demo program that comes with it without a hitch. However when I compile it for release and include the /obj/Release/CodeSamples.dll as a reference in my C# project, the examples won't work any more. Specifically, selecting an item doesn't work. I can add and display items properly, but when I click on an item, in the VB project it displays the first column's value, in the C# project, it doesn't display anything.
Any idea what I'm doing wrong?
once code is compiled into a dll it no longer matters if it was VB.net or C#. They all get compiled into IL. Chances are your problem is with your own code. Also don't add reference to the dll under the obj directory. Instead go for the one under the bin directory.
I'm not familiar with this specific control, but did you use a sample VB code snippet, porting it to C# in order to consume the control in your C# app? I think VB arrays are 1-based whereas C# arrays are 0-based, so perhaps you have a 1-off problem in your C# code that accesses the control.
Just a guess.