Xamarin.Forms 3.6 has included the CarouselView, so I cant use the nuget package anymore, but shipped version seems to be lacking some features, more specifically indicators seems to be missing entirely?
Here is my old code, which does not compile anymore:
// Create the carousel
_carouselView = new CarouselView()
{
VerticalOptions = LayoutOptions.FillAndExpand,
HorizontalOptions = LayoutOptions.FillAndExpand,
};
_carouselView.ItemTemplate = template;
_carouselView.SetBinding(ItemsView.ItemsSourceProperty, nameof(_viewModel.CarouselItems));
_carouselView.SetBinding(CarouselView.PositionProperty, nameof(_viewModel.Position));
// Create page-indicator
var indicator = new CarouselIndicators { ItemsSource = _viewModel.CarouselItems };
indicator.Margin = new Thickness(20, 20, 20, 0);
indicator.SetBinding(CarouselIndicators.PositionProperty, nameof(_viewModel.Position));
CarouselView.Position and CarouselIndicators are not there in 3.6 :( Do I need to implement indicators manually in 3.6?
As Xamarin.Forms 3.6 includes an implementation of CarouselView, if you upgrade from using Xamarin.Forms<3.6 and Xamarin.Forms.CarouselView to Xamarin.Forms 3.6 it is going to break. Because
the Xamarin.Forms.CarouselView nuget package is deprecated and hasn't been updated for 2 years
by having Xamarin.Forms 3.6 and Xamarin.Forms.CarouselView in parallel you will have a naming conflict between the 2 CarouselView elements
the Xamarin.Forms.CarouselView implementation in Xamarin.Forms 3.6 doesn't contain a Position property
A lot of projects switched to a community implementation of CarouselViews :
https://forums.xamarin.com/discussion/106176/carouselview-position-problem
https://forums.xamarin.com/discussion/129883/i-am-unable-to-set-the-particular-page-in-carousel-view
https://forums.xamarin.com/discussion/132858/carouselview-state-of-the-union
https://forums.xamarin.com/discussion/141384/how-to-implement-a-simple-carouselview
Solution for you would be :
Remove Xamarin.Forms.CarouselView
Add https://github.com/AndreiMisiukevich/CardView (CardsView nuget package)
Upgrade Xamarin.Forms to 3.6
Change
_carouselView.SetBinding(CarouselView.PositionProperty, nameof(_viewModel.Position));
to
_carouselView.SetBinding(CardsView.SelectedIndexProperty, nameof(_viewModel.Position));
Related
According to Android 12 documentation there is special in/out-call notification that will show that called 'prominent chip'.
It's looking like that:
I tried to use the code from Android example:
// Create a new call with the user as caller.
Person incoming_caller = new Person.Builder()
.setName("Jane Doe")
.setImportant(true)
.build();
Notification.Builder builder = Notification.Builder(context, CHANNEL_ID)
.setContentIntent(contentIntent)
.setSmallIcon(smallIcon)
.setStyle(
Notification.CallStyle.forIncomingCall(caller, declineIntent, answerIntent))
.addPerson(incoming_caller);
In my application im using NotificationCompat and NotificationCompat.Builder
but this line Notification.CallStyle.forIncomingCall is refer to non Compat versions so I can't use the logic of forIncomingCall to my existing notification.
The NotificationCompat class from AndroidX hasn't been updated to include this new style yet - you can search NotificationCompat on https://cs.android.com to check the latest version of the file, and then you'll have to wait for a new release of the androidx.core:core library.
In the meantime, you'll have to use the platform Notification type if you want to use the new call style:
if (Build.VERSION.SDK_INT >= 31) {
// Use Notification with Notification.CallStyle
} else {
// use NotificationCompat
}
I'm developing an extension for Visual Studio that includes a XAML view inside a VS window. I want the extension to look and feel like the native UI. The extension is currently running and working fine in VS2017 and VS2019 using the following code to transform a moniker to a WPF BitmapSource that can be used directly from XAML:
public static BitmapSource GetIconForImageMoniker(ImageMoniker? imageMoniker, int sizeX, int sizeY)
{
if (imageMoniker == null)
{
return null;
}
IVsImageService2 vsIconService = ServiceProvider.GlobalProvider.GetService(typeof(SVsImageService)) as IVsImageService2;
if (vsIconService == null)
{
return null;
}
ImageAttributes imageAttributes = new ImageAttributes
{
Flags = (uint)_ImageAttributesFlags.IAF_RequiredFlags,
ImageType = (uint)_UIImageType.IT_Bitmap,
Format = (uint)_UIDataFormat.DF_WPF,
LogicalHeight = sizeY,
LogicalWidth = sizeX,
StructSize = Marshal.SizeOf(typeof(ImageAttributes))
};
IVsUIObject result = vsIconService.GetImage(imageMoniker.Value, imageAttributes);
object data;
result.get_Data(out data);
BitmapSource glyph = data as BitmapSource;
if (glyph != null)
{
glyph.Freeze();
}
return glyph;
}
This method is a direct copy-paste from the WpfUtil class available in multiple of Mads Kristensen's extensions.
As already mentioned, this works fine in VS2017 and VS2019. Now I want this running in VS2022 as well. The extension shows up inside VS2022 but the icons are no longer shown. The problem is that this returns null in VS2022 but not in the previous versions:
ServiceProvider.GlobalProvider.GetService(typeof(SVsImageService)) as IVsImageService2;
Does anyone know how to make this work in VS2022 as well?
This is caused by changes to the interop libraries in VS2022. Namely, they've all been consolidated to a single library (you can see the details here).
This does break compatibility with targeting prior versions of Visual Studio. There is a guide for migrating extensions to VS2022, but to summarize, the guidance is to:
Refactor the source code into a Shared Project.
Create a new VSIX projects targeting VS2022 and the VSIX project you have now would remain for targeting prior versions.
I'm porting a library from .NET Framework 4.6.1 to .NET Standard 2.0. In Framework, the NamedPipeServerStream constructor could take a PipeSecurity parameter, but that isn't an option in Core. How do you set the security of a NamedPipeServerStream in Core?
Net 6.0 has introduced NamedPipeServerStreamAcl Class.
You can use the Create method to create the stream with PipeSecurity...
using System.IO.Pipes;
using System.Security.AccessControl;
using System.Security.Principal;
if (!System.OperatingSystem.IsWindows())
throw new PlatformNotSupportedException("Windows only");
SecurityIdentifier securityIdentifier = new SecurityIdentifier(
WellKnownSidType.AuthenticatedUserSid, null);
PipeSecurity pipeSecurity = new PipeSecurity();
pipeSecurity.AddAccessRule(new PipeAccessRule(securityIdentifier,
PipeAccessRights.ReadWrite | PipeAccessRights.CreateNewInstance,
AccessControlType.Allow));
NamedPipeServerStream stream = NamedPipeServerStreamAcl.Create(
"SecurityTestPipe", PipeDirection.InOut,
NamedPipeServerStream.MaxAllowedServerInstances,
PipeTransmissionMode.Byte, PipeOptions.Asynchronous, 0, 0, pipeSecurity);
Apparently it's a known issue
System.IO.Pipes.AccessControl package does not work #26869. There's a workaround mentioned in the last post suggesting usage of NamedPipeServerStream.NetFrameworkVersion nuget package which will expose NamedPipeServerStreamConstructors.New(...) which should mirror behavior of all the full .NET Framework constructors.
Follows a code sample from the nuget's github
using System.IO.Pipes;
var pipeSecurity = new PipeSecurity();
pipeSecurity.AddAccessRule(new PipeAccessRule(new SecurityIdentifier(WellKnownSidType.BuiltinUsersSid, null), PipeAccessRights.ReadWrite, AccessControlType.Allow));
using var serverStream = NamedPipeServerStreamConstructors.New(pipeName, PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.Asynchronous | PipeOptions.WriteThrough, 0, 0, pipeSecurity);
Setup
Robolectric: 4.2.1
AndroidX fragment-testing: 1.1.0-alpha05
Background
With AndroidX comes new ways of testing fragments:
Source:
https://developer.android.com/training/basics/fragments/testing
Robolectric is compatible with AndroidX and intends to deprecate functionality that mirrors AndroidX capabilities.
Source:
http://robolectric.org/androidx_test/
But in Robolectric you could test the behavior of the options menu, e.g. with something like this (I know it looks cluttered but the FragmentController doesn't work well in some cases):
#Test
public void OnPrepareOptionsMenu_WhenX_ShowsMenuActionsCorrectly() {
setupX();
final Bundle instanceState = new Bundle();
instanceState.putString(FooActivity.ARG_UUID, x.getUuid());
final FooActivity activity = Robolectric.buildActivity(FooActivity.class)
.create(instanceState).start().visible().get();
activity.getSupportFragmentManager().beginTransaction()
.add(R.id.container_x_fragment_details, fragment).commit();
final Context context = fragment.requireContext();
final Menu menu = new RoboMenu(context);
fragment.onCreateOptionsMenu(menu, new MenuInflater(context));
fragment.onPrepareOptionsMenu(menu);
assertThat(menu.findItem(R.id.action_y).isVisible(), is(true));
assertThat(menu.findItem(R.id.action_z).isVisible(), is(true));
}
What is the API to do something similar (without using espresso) in AndroidX?
The RoboMenu construct does not seem to play well with AndroidX and this doesn't work:
fragmentScenario.onFragment(fragment -> {
final Activity activity = fragment.requireActivity();
assertThat(activity.findViewById(R.id.y).getVisibility(), is(View.VISIBLE));
assertThat(activity.findViewById(R.id.z).getVisibility(), is(View.VISIBLE));
});
I found an issue on Here Android SDK 3.2, when recalculation happened during navigation, the new route can not be seen on map, only white turn arrow on map. The previous SDK version don't has such issue.
It is a new Issue?
You can workaround this regression using NavigationManager.RerouteListener
private NavigationManager.RerouteListener rerouteHandler = new NavigationManager.RerouteListener() {
#Override
public void onRerouteEnd(Route route) {
super.onRerouteEnd(route);
map.addMapObject(new MapRoute(route);
}
...
};
...
NavigationManager.getInstance().addRerouteListener(new WeakReference<>(rerouteHandler));