Skip to content
2 changes: 1 addition & 1 deletion docs/high-performance/Memory2D.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ This configuration allows `Memory2D<T>` to be extremely flexible in the way it m
- A 2D `T[,]` array, mapped directly to a `Memory2D<T>` instance.
- A 3D `T[,,]` array, with a `Memory2D<T>` instance representing a given depth slice (a layer).

The `Memory<T>` type also exposes a number of utility methods, including most of the same API surface that the standard `Memory<T>` implements. For instance, it includes a `Slice(int, int)` method that makes it easy to do 2D slicing operations directly on the virtual 2D memory location, with the `Memory2D<T>` instance automatically adjusting the necessary parameters internally to shift its mapping on the right memory area(s) corresponding to the requested result.
The `Memory2D<T>` type also exposes a number of utility methods, including most of the same API surface that the standard `Memory<T>` implements. For instance, it includes a `Slice(int, int)` method that makes it easy to do 2D slicing operations directly on the virtual 2D memory location, with the `Memory2D<T>` instance automatically adjusting the necessary parameters internally to shift its mapping on the right memory area(s) corresponding to the requested result.

## Syntax

Expand Down
2 changes: 1 addition & 1 deletion docs/high-performance/ParallelHelper.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dev_langs:

The [`ParallelHelper`](/dotnet/api/microsoft.toolkit.highperformance.helpers.parallelhelper) contains high performance APIs to work with parallel code. It contains performance oriented methods that can be used to quickly setup and execute parallel operations over a given data set or iteration range or area.

> **Platform APIs:** [`ParallelHelper`](/dotnet/api/microsoft.toolkit.highperformance.helpers.parallelhelper), [`IAction`](/dotnet/api/microsoft.toolkit.highperformance.helpers.IAction), [`IAction2D`](/dotnet/api/microsoft.toolkit.highperformance.helpers.IAction2D), [`IRefAction<T>`](/dotnet/api/microsoft.toolkit.highperformance.helpers.IRefAction-1), [`IInAction<T><T>`](/dotnet/api/microsoft.toolkit.highperformance.helpers.IInAction-1)
> **Platform APIs:** [`ParallelHelper`](/dotnet/api/microsoft.toolkit.highperformance.helpers.parallelhelper), [`IAction`](/dotnet/api/microsoft.toolkit.highperformance.helpers.IAction), [`IAction2D`](/dotnet/api/microsoft.toolkit.highperformance.helpers.IAction2D), [`IRefAction<T>`](/dotnet/api/microsoft.toolkit.highperformance.helpers.IRefAction-1), [`IInAction<T>`](/dotnet/api/microsoft.toolkit.highperformance.helpers.IInAction-1)

## How it works

Expand Down
2 changes: 1 addition & 1 deletion docs/high-performance/Span2D.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Span2D<int> span = array;
// The memory directly maps the 2*3 array here

span[0, 0] = 10;
span[2, 1] = 20;
span[1, 1] = 20;

// The array is now:
// { 10, 2, 3 },
Expand Down
2 changes: 1 addition & 1 deletion docs/high-performance/SpanOwner.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Span<int> span = buffer.Span;
The `SpanOwner<T>` instance will internally rent an array, and will take care of returning it to the pool when it goes out of scope. We no longer need to use a `try/finally` block either, as the C# compiler will add that automatically when expanding that `using` statement. As such, the `SpanOwner<T>` type can be seen as a lightweight wrapper around the `ArrayPool<T>` APIs, which makes them both more compact and easier to use, reducing the amount of code that needs to be written to properly rent and dispose short lived buffers. You can see how using `SpanOwner<T>` makes the code much shorter and more straightforward.

> [!NOTE]
> As this is a stack-only type, it relies on the duck-typed `IDisposable` pattern introduced with C# 8. That is shown in the sample above: the `SpanOwner<T>` type is being used within a `using` block despite the fact that the type doesn't implement the `IDisposable` interface at all, and it's also never boxed. The functionality is just the same: as soon as the buffer goes out of scope, it is automatically disposed. The APIs in `SpanOwner{T}` rely on this pattern for extra performance: they assume that the underlying buffer will never be disposed as long as the `SpanOwner<T>` type is in scope, and they don't perform the additional checks that are done in `MemoryOwner<T>` to ensure that the buffer is in fact still available before returning a `Memory<T>` or `Span<T>` instance from it. As such, this type should always be used with a `using` block or expression. Not doing so will cause the underlying buffer not to be returned to the shared pool. Technically the same can also be achieved by manually calling `Dispose` on the `SpanOwner<T>` type (which doesn't require C# 8), but that is error prone and hence not recommended.
> As this is a stack-only type, it relies on the duck-typed `IDisposable` pattern introduced with C# 8. That is shown in the sample above: the `SpanOwner<T>` type is being used within a `using` block despite the fact that the type doesn't implement the `IDisposable` interface at all, and it's also never boxed. The functionality is just the same: as soon as the buffer goes out of scope, it is automatically disposed. The APIs in `SpanOwner<T>` rely on this pattern for extra performance: they assume that the underlying buffer will never be disposed as long as the `SpanOwner<T>` type is in scope, and they don't perform the additional checks that are done in `MemoryOwner<T>` to ensure that the buffer is in fact still available before returning a `Memory<T>` or `Span<T>` instance from it. As such, this type should always be used with a `using` block or expression. Not doing so will cause the underlying buffer not to be returned to the shared pool. Technically the same can also be achieved by manually calling `Dispose` on the `SpanOwner<T>` type (which doesn't require C# 8), but that is error prone and hence not recommended.

## Examples

Expand Down
4 changes: 4 additions & 0 deletions docs/maui/TOC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ items:
href: views/Popup.md
- name: "Popup Service"
href: views/popup-service.md
- name: "Customizing Popup behavior and appearance"
href: views/popup/popup-options.md
- name: "Returning a value from a Popup"
href: views/popup/popup-result.md
- name: SemanticOrderView
href: views/semantic-order-view.md
- name: C# Markup
Expand Down
6 changes: 4 additions & 2 deletions docs/maui/behaviors/animation-behavior.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ms.date: 09/16/2022

# AnimationBehavior

The `AnimationBehavior` is a `Behavior` that provides the ability to animate any `VisualElement` it is attached to. By default a `TapGestureRecognizer` is attached to the `VisualElement` and triggers the associated animation when that recognizer detects that the user has tapped or clicked on the `VisualElement`.
The `AnimationBehavior` is a `Behavior` that provides the ability to animate any `VisualElement` it is attached to. Setting `AnimateOnTap` to `true` adds a `TapGestureRecognizer` to the `VisualElement` and triggers the associated animation when that recognizer detects that the user has tapped or clicked on the `VisualElement`.

The `AnimationType` property is required to be set, possible options for this can be found at [Animations](../animations/index.md).

Expand Down Expand Up @@ -35,7 +35,7 @@ The following examples show how to add the `AnimationBehavior` to a `Label` and

<Label Text="Click this Label">
<Label.Behaviors>
<toolkit:AnimationBehavior>
<toolkit:AnimationBehavior AnimateOnTap="True">
<toolkit:AnimationBehavior.AnimationType>
<toolkit:FadeAnimation Opacity="0.5" />
</toolkit:AnimationBehavior.AnimationType>
Expand All @@ -62,6 +62,7 @@ class AnimationBehaviorPage : ContentPage

var animationBehavior = new AnimationBehavior
{
AnimateOnTap = true,
AnimationType = new FadeAnimation
{
Opacity = 0.5
Expand Down Expand Up @@ -90,6 +91,7 @@ class AnimationBehaviorPage : ContentPage
.Text("Click this label")
.Behaviors(new AnimationBehavior
{
AnimateOnTap = true,
AnimationType = new FadeAnimation
{
Opacity = 0.5
Expand Down
2 changes: 1 addition & 1 deletion docs/maui/essentials/speech-to-text.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public static class MauiProgram

builder.Services.AddSingleton<ISpeechToText>(SpeechToText.Default);
// For offline recognition
// builder.Services.AddSingleton<IOfflineSpeechToText>(OfflineSpeechToText.Default);
// builder.Services.AddSingleton<ISpeechToText>(OfflineSpeechToText.Default);
return builder.Build();
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/maui/images/views/popup/popup-no-border.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/maui/images/views/popup/popup-no-shadow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/maui/images/views/popup/popup-result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
64 changes: 28 additions & 36 deletions docs/maui/views/MediaElement.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,34 @@ remote URL with artwork for the lockscreen. It should be at least 1080P for best
> You can set the metadata in either XAML or code behind. If you are setting it in code behind you need to set the source in code behind. The source should
be set last. If you set the metadata in XAML or in constructor this note can be safely ignored.

### Using TextureView

A `MediaElement` can use `TextureView` on Android Platform. The platform default behavior is to use `SurfaceView`. Using Texture View adds support
to allow transparencies and other effects. This is set by changing the builder to use

```csharp
.UseMauiCommunityToolkitMediaElement(static options =>
{
options.SetDefaultAndroidViewType(AndroidViewType.TextureView);
})
```

You can set `TextureView` for each media element you use as well. It can be set in `XAML` and codebehind. Using it this way will override the builder command `.UseMauiCommunityToolkitMediaElement()`.

```csharp
var mediaElement = new MediaElement
{
AndroidViewType = AndroidViewType.TextureView
}
```

```xaml
<toolkit:MediaElement AndroidViewType="TextureView" />
```

> [!IMPORTANT]
> We do not recommend using TextureView unless you have a specific need for it. It has possible performance related issues if enabled and is recommended only for those that need transparencies and other advanced features.

### Play local media

Local media can be played from the following sources:
Expand Down Expand Up @@ -351,42 +379,6 @@ In this example, the [`Slider`](xref:Microsoft.Maui.Controls.Slider) data binds

For more information about using a [`Slider`](xref:Microsoft.Maui.Controls.Slider) see, [.NET MAUI Slider](/dotnet/maui/user-interface/controls/slider)

## Clean up `MediaElement` resources

To prevent memory leaks you will have to free the resources of `MediaElement`. This can be done by disconnecting the handler.
Where you need to do this is dependant on where and how you use `MediaElement` in your app, but typically if you have a `MediaElement` on a single page and are not playing media in the background, you want to free the resources when the user navigates away from the page.

Below you can find a snippet of sample code which shows how to do this. First, make sure to hook up the `Unloaded` event on your page.

```xaml
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
x:Class="MediaElementDemos.FreeResourcesPage"
Title="Free Resources"
Unloaded="ContentPage_Unloaded">

<toolkit:MediaElement x:Name="mediaElement"
ShouldAutoPlay="False"
... />
</ContentPage>
```

Then in the code-behind, call the method to disconnect the handler.

```csharp
public partial class FreeResourcesPage : ContentPage
{
void ContentPage_Unloaded(object? sender, EventArgs e)
{
// Stop and cleanup MediaElement when we navigate away
mediaElement.Handler?.DisconnectHandler();
}
}
```

To read more about handlers, please see the .NET MAUI documentation on [Handlers](/dotnet/maui/user-interface/handlers).

## Properties

|Property |Type |Description |Default Value |
Expand Down
Loading