Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e494bd2
Move `[BindableProperty]` and `[AttachedBindableProperty<T>]` to `Com…
TheCodeTraveler Feb 7, 2026
19d3811
Remove Bindable Property Source Generator from `CommunityToolkit.Mau…
TheCodeTraveler Feb 7, 2026
cec388e
Use MediaElementDefaults
TheCodeTraveler Feb 7, 2026
ce7504e
Remove `[BindableProperty]`
TheCodeTraveler Feb 7, 2026
b68db09
Update TextColorToGenerator.cs
TheCodeTraveler Feb 7, 2026
407abcd
Revert "Update TextColorToGenerator.cs"
TheCodeTraveler Feb 7, 2026
a9da4a5
Revert DisableTextColorToGenerator
TheCodeTraveler Feb 7, 2026
2c86140
Remove unused method
TheCodeTraveler Feb 7, 2026
d2b0de4
Fix folder name
TheCodeTraveler Feb 7, 2026
5742a1d
Merge branch 'Resolve-CS0436-Caused-by-Bindable-Property-Attribute' o…
TheCodeTraveler Feb 7, 2026
048379e
Fix naming
TheCodeTraveler Feb 7, 2026
b3a6879
Remove nullable
TheCodeTraveler Feb 7, 2026
f2346bf
Update CameraView.shared.cs
TheCodeTraveler Feb 7, 2026
8b86140
Update AttachedBindablePropertyAttribute.shared.cs
TheCodeTraveler Feb 7, 2026
cdfe671
Update XML Docs
TheCodeTraveler Feb 7, 2026
e82db64
Update MediaElement.shared.cs
TheCodeTraveler Feb 7, 2026
812da7d
Update src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs
TheCodeTraveler Feb 7, 2026
0fc3ec6
Update src/CommunityToolkit.Maui/Primitives/BindablePropertySourceGen…
TheCodeTraveler Feb 7, 2026
feff219
Update src/CommunityToolkit.Maui/Primitives/BindablePropertySourceGen…
TheCodeTraveler Feb 7, 2026
4e6cc8d
Update src/CommunityToolkit.Maui.MediaElement/MediaElement.shared.cs
TheCodeTraveler Feb 7, 2026
ce63501
Update src/CommunityToolkit.Maui.MediaElement/MediaElement.shared.cs
TheCodeTraveler Feb 7, 2026
32372b4
Update XML Docs
TheCodeTraveler Feb 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,4 @@
<None Include="..\CommunityToolkit.Maui.Camera.Analyzers.CodeFixes\bin\$(Configuration)\netstandard2.0\CommunityToolkit.Maui.Camera.Analyzers.CodeFixes.dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
</ItemGroup>

<ItemGroup>
<CompilerVisibleProperty Include="DisableTextColorToGenerator" />
<ProjectReference Include="..\CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>

</Project>
132 changes: 108 additions & 24 deletions src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,82 @@ namespace CommunityToolkit.Maui.Views;
/// </summary>
public partial class CameraView : View, ICameraView, IDisposable
{
static readonly BindablePropertyKey isAvailablePropertyKey =
BindableProperty.CreateReadOnly(nameof(IsAvailable), typeof(bool), typeof(CameraView), CameraViewDefaults.IsAvailable);

/// <summary>
/// Backing <see cref="BindableProperty"/> for the <see cref="CameraFlashMode"/> property.
/// </summary>
public static readonly BindableProperty CameraFlashModeProperty =
BindableProperty.Create(nameof(CameraFlashMode), typeof(CameraFlashMode), typeof(CameraView), CameraViewDefaults.CameraFlashMode);

/// <summary>
/// Backing <see cref="BindableProperty"/> for the <see cref="IsTorchOn"/> property.
/// </summary>
public static readonly BindableProperty IsTorchOnProperty =
BindableProperty.Create(nameof(IsTorchOn), typeof(bool), typeof(CameraView), CameraViewDefaults.IsTorchOn);

/// <summary>
/// Backing <see cref="BindableProperty"/> for the <see cref="IsAvailable"/> property.
/// </summary>
public static readonly BindableProperty IsAvailableProperty = isAvailablePropertyKey.BindableProperty;

static readonly BindablePropertyKey isBusyPropertyKey =
BindableProperty.CreateReadOnly(nameof(IsBusy), typeof(bool), typeof(CameraView), CameraViewDefaults.IsCameraBusy);

/// <summary>
/// Backing <see cref="BindableProperty"/> for the <see cref="IsBusy"/> property.
/// </summary>
public static readonly BindableProperty IsBusyProperty = isBusyPropertyKey.BindableProperty;

/// <summary>
/// Backing <see cref="BindableProperty"/> for the <see cref="SelectedCamera"/> property.
/// </summary>
public static readonly BindableProperty SelectedCameraProperty = BindableProperty.Create(nameof(SelectedCamera),
typeof(CameraInfo), typeof(CameraView), null, defaultBindingMode: BindingMode.TwoWay);

/// <summary>
/// Backing <see cref="BindableProperty"/> for the <see cref="ZoomFactor"/> property.
/// </summary>
public static readonly BindableProperty ZoomFactorProperty =
BindableProperty.Create(nameof(ZoomFactor), typeof(float), typeof(CameraView), CameraViewDefaults.ZoomFactor, coerceValue: CoerceZoom, defaultBindingMode: BindingMode.TwoWay);

/// <summary>
/// Bindable property for the <see cref="ImageCaptureResolution"/> property.
/// </summary>
public static readonly BindableProperty ImageCaptureResolutionProperty = BindableProperty.Create(nameof(ImageCaptureResolution),
typeof(Size), typeof(CameraView), CameraViewDefaults.ImageCaptureResolution, defaultBindingMode: BindingMode.TwoWay);

/// <summary>
/// Bindable property for the <see cref="CaptureImageCommand"/> property.
/// </summary>
public static readonly BindableProperty CaptureImageCommandProperty =
BindableProperty.CreateReadOnly(nameof(CaptureImageCommand), typeof(Command<CancellationToken>), typeof(CameraView), null, BindingMode.OneWayToSource, defaultValueCreator: CreateCaptureImageCommand).BindableProperty;

/// <summary>
/// Bindable property for the <see cref="StartCameraPreviewCommand"/> property.
/// </summary>
public static readonly BindableProperty StartCameraPreviewCommandProperty =
BindableProperty.CreateReadOnly(nameof(StartCameraPreviewCommand), typeof(Command<CancellationToken>), typeof(CameraView), null, BindingMode.OneWayToSource, defaultValueCreator: CreateStartCameraPreviewCommand).BindableProperty;

/// <summary>
/// Bindable property for the <see cref="StopCameraPreviewCommand"/> property.
/// </summary>
public static readonly BindableProperty StopCameraPreviewCommandProperty =
BindableProperty.CreateReadOnly(nameof(StopCameraPreviewCommand), typeof(Command<CancellationToken>), typeof(CameraView), null, BindingMode.OneWayToSource, defaultValueCreator: CreateStopCameraPreviewCommand).BindableProperty;

/// <summary>
/// Bindable property for the <see cref="StartVideoRecordingCommand"/> property.
/// </summary>
public static readonly BindableProperty StartVideoRecordingCommandProperty =
BindableProperty.CreateReadOnly(nameof(StartVideoRecordingCommand), typeof(Command<Stream>), typeof(CameraView), null, BindingMode.OneWayToSource, defaultValueCreator: CreateStartVideoRecordingCommand).BindableProperty;

/// <summary>
/// Bindable property for the <see cref="StopVideoRecordingCommand"/> property.
/// </summary>
public static readonly BindableProperty StopVideoRecordingCommandProperty =
BindableProperty.CreateReadOnly(nameof(StopVideoRecordingCommand), typeof(Command<CancellationToken>), typeof(CameraView), null, BindingMode.OneWayToSource, defaultValueCreator: CreateStopVideoRecordingCommand).BindableProperty;

readonly SemaphoreSlim captureImageSemaphoreSlim = new(1, 1);
readonly WeakEventManager weakEventManager = new();

Expand Down Expand Up @@ -39,77 +115,85 @@ public event EventHandler<MediaCapturedEventArgs> MediaCaptured
static ICameraProvider CameraProvider => IPlatformApplication.Current?.Services.GetRequiredService<ICameraProvider>() ?? throw new CameraException("Unable to retrieve CameraProvider");

/// <inheritdoc cref="ICameraView.IsAvailable"/>
[BindableProperty]
public partial bool IsAvailable { get; } = CameraViewDefaults.IsAvailable;
public bool IsAvailable => (bool)GetValue(IsAvailableProperty);

/// <inheritdoc cref="ICameraView.IsBusy"/>
[BindableProperty]
public partial bool IsBusy { get; } = CameraViewDefaults.IsCameraBusy;
public bool IsBusy => (bool)GetValue(IsBusyProperty);

/// <summary>
/// Gets the <see cref="Command{CancellationToken}"/> that triggers an image capture.
/// </summary>
/// <remarks>
/// <see cref="CaptureImageCommand"/> has a <see cref="Type"/> of Command&lt;CancellationToken&gt; which requires a <see cref="CancellationToken"/> as a CommandParameter. See <see cref="Command{CancellationToken}"/> and <see cref="System.Windows.Input.ICommand.Execute(object)"/> for more information on passing a <see cref="CancellationToken"/> into <see cref="Command{T}"/> as a CommandParameter
/// </remarks>
[BindableProperty(DefaultValueCreatorMethodName = nameof(CreateCaptureImageCommand), DefaultBindingMode = BindingMode.OneWayToSource)]
public partial Command<CancellationToken> CaptureImageCommand { get; }
public Command<CancellationToken> CaptureImageCommand => (Command<CancellationToken>)GetValue(CaptureImageCommandProperty);

/// <summary>
/// Gets the <see cref="Command{CancellationToken}"/> that starts the camera preview.
/// </summary>
/// <remarks>
/// <see cref="StartCameraPreviewCommand"/> has a <see cref="Type"/> of Command&lt;CancellationToken&gt; which requires a <see cref="CancellationToken"/> as a CommandParameter. See <see cref="Command{CancellationToken}"/> and <see cref="System.Windows.Input.ICommand.Execute(object)"/> for more information on passing a <see cref="CancellationToken"/> into <see cref="Command{T}"/> as a CommandParameter
/// </remarks>
[BindableProperty(DefaultValueCreatorMethodName = nameof(CreateStartCameraPreviewCommand), DefaultBindingMode = BindingMode.OneWayToSource)]
public partial Command<CancellationToken> StartCameraPreviewCommand { get; }
public Command<CancellationToken> StartCameraPreviewCommand => (Command<CancellationToken>)GetValue(StartCameraPreviewCommandProperty);

/// <summary>
/// Gets the <see cref="Command{CancellationToken}"/> that stops the camera preview.
/// </summary>
/// <remarks>
/// <see cref="StopCameraPreviewCommand"/> has a <see cref="Type"/> of Command&lt;CancellationToken&gt; which requires a <see cref="CancellationToken"/> as a CommandParameter. See <see cref="Command{CancellationToken}"/> and <see cref="System.Windows.Input.ICommand.Execute(object)"/> for more information on passing a <see cref="CancellationToken"/> into <see cref="Command{T}"/> as a CommandParameter
/// </remarks>
[BindableProperty(DefaultValueCreatorMethodName = nameof(CreateStopCameraPreviewCommand), DefaultBindingMode = BindingMode.OneWayToSource)]
public partial Command<CancellationToken> StopCameraPreviewCommand { get; }
public Command<CancellationToken> StopCameraPreviewCommand => (Command<CancellationToken>)GetValue(StopCameraPreviewCommandProperty);

/// <summary>
/// Gets the <see cref="Command{Stream}"/> that starts video recording.
/// </summary>
/// <remarks>
/// <see cref="StartVideoRecordingCommand"/> has a <see cref="Type"/> of Command&lt;Stream&gt; which requires a <see cref="Stream"/> as a CommandParameter. See <see cref="Command{Stream}"/> and <see cref="System.Windows.Input.ICommand.Execute(object)"/> for more information on passing a <see cref="Stream"/> into <see cref="Command{T}"/> as a CommandParameter
/// </remarks>
[BindableProperty(DefaultValueCreatorMethodName = nameof(CreateStartVideoRecordingCommand), DefaultBindingMode = BindingMode.OneWayToSource)]
public partial Command<Stream> StartVideoRecordingCommand { get; }
public Command<Stream> StartVideoRecordingCommand => (Command<Stream>)GetValue(StartVideoRecordingCommandProperty);

/// <summary>
/// Gets the <see cref="Command{CancellationToken}"/> that stops video recording.
/// </summary>
/// <remarks>
/// <see cref="StopVideoRecordingCommand"/> has a <see cref="Type"/> of Command&lt;CancellationToken&gt; which requires a <see cref="CancellationToken"/> as a CommandParameter. See <see cref="Command{CancellationToken}"/> and <see cref="System.Windows.Input.ICommand.Execute(object)"/> for more information on passing a <see cref="CancellationToken"/> into <see cref="Command{T}"/> as a CommandParameter
/// </remarks>
[BindableProperty(DefaultValueCreatorMethodName = nameof(CreateStopVideoRecordingCommand), DefaultBindingMode = BindingMode.OneWayToSource)]
public partial Command<CancellationToken> StopVideoRecordingCommand { get; }
public Command<CancellationToken> StopVideoRecordingCommand => (Command<CancellationToken>)GetValue(StopVideoRecordingCommandProperty);

/// <inheritdoc cref="ICameraView.CameraFlashMode"/>
[BindableProperty]
public partial CameraFlashMode CameraFlashMode { get; set; } = CameraViewDefaults.CameraFlashMode;
public CameraFlashMode CameraFlashMode
{
get => (CameraFlashMode)GetValue(CameraFlashModeProperty);
set => SetValue(CameraFlashModeProperty, value);
}

/// <inheritdoc cref="ICameraView.SelectedCamera"/>
[BindableProperty(DefaultBindingMode = BindingMode.TwoWay)]
public partial CameraInfo? SelectedCamera { get; set; }
public CameraInfo? SelectedCamera
{
get => (CameraInfo?)GetValue(SelectedCameraProperty);
set => SetValue(SelectedCameraProperty, value);
}

/// <inheritdoc cref="ICameraView.ZoomFactor"/>
[BindableProperty(DefaultBindingMode = BindingMode.TwoWay, CoerceValueMethodName = nameof(CoerceZoom))]
public partial float ZoomFactor { get; set; } = CameraViewDefaults.ZoomFactor;
public float ZoomFactor
{
get => (float)GetValue(ZoomFactorProperty);
set => SetValue(ZoomFactorProperty, value);
}

/// <inheritdoc cref="ICameraView.ImageCaptureResolution"/>
[BindableProperty(DefaultBindingMode = BindingMode.TwoWay)]
public partial Size ImageCaptureResolution { get; set; } = CameraViewDefaults.ImageCaptureResolution;
public Size ImageCaptureResolution
{
get => (Size)GetValue(ImageCaptureResolutionProperty);
set => SetValue(ImageCaptureResolutionProperty, value);
}

/// <inheritdoc cref="ICameraView.IsTorchOn"/>
[BindableProperty]
public partial bool IsTorchOn { get; set; } = CameraViewDefaults.IsTorchOn;
public bool IsTorchOn
{
get => (bool)GetValue(IsTorchOnProperty);
set => SetValue(IsTorchOnProperty, value);
}

new CameraViewHandler Handler => (CameraViewHandler)(base.Handler ?? throw new InvalidOperationException("Unable to retrieve Handler"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" Condition=" '$(Configuration)'=='Release' " PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<CompilerVisibleProperty Include="DisableTextColorToGenerator" />
<ProjectReference Include="..\CommunityToolkit.Maui.SourceGenerators\CommunityToolkit.Maui.SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="ResourceDictionary.windows.xaml">
<LogicalName>ResourceDictionary.windows.xaml</LogicalName>
Expand Down
Loading
Loading