Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with InkCanvas Drawing on Windows 10 in UWP ApplicationBug title #9347

Closed
Marim99 opened this issue Feb 19, 2024 · 4 comments
Closed
Labels
appModel-UWP Exclusive to WinUI 2 UWP apps area-External Not owned by the WinUI team, not actionable in this repository. area-InkCanvas bug Something isn't working needs-author-feedback Asked author to supply more information. no-recent-activity

Comments

@Marim99
Copy link

Marim99 commented Feb 19, 2024

Describe the bug

I have developed an image editor using the InkCanvas control in my Universal Windows Platform (UWP) application. Surprisingly, it works perfectly fine on Windows 11. However, when testing the app on Windows 10, I encountered an issue where the InkCanvas doesn't draw on the image.

Problem Description:
Although the ink toolbar is visible and functional, allowing users to select colors and tools, the actual drawing on the image doesn't happen on Windows 10.

Steps to reproduce the bug

  1. Launch the UWP application on a device running Windows 10.
  2. Open the image editor dialog.
  3. Attempt to draw on the image using the InkCanvas.

Expected behavior

The InkCanvas should allow drawing on the image, similar to its behavior on Windows 11.

Actual Behavior:

The InkCanvas appears functional, but drawing on the image does not occur on Windows 10.

Screenshots

XAML Component Snippet:

<ContentDialog
    x:Class="eseua.Views.ImageEditorDialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:helpers="using:eseua.Helpers"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    Margin="5"
    CornerRadius="{StaticResource OverlayCornerRadius}"
    FullSizeDesired="True"
    PrimaryButtonStyle="{StaticResource DefaultButtonStyle}"
    PrimaryButtonText="{helpers:ResourceString Name=EditImageDialog_PrimaryButtonText}"
    SecondaryButtonStyle="{StaticResource ThemeAwareContentDialogSecondaryButtonStyle}"
    SecondaryButtonText="{helpers:ResourceString Name=Logout_Dialog_No}"
    mc:Ignorable="d">
    <ContentDialog.Resources>
        <x:Double x:Key="ContentDialogWidth">700</x:Double>
        <x:Double x:Key="ContentDialogMinWidth">200</x:Double>
        <x:Double x:Key="ContentDialogMaxWidth">1000</x:Double>
    </ContentDialog.Resources>
    <Grid
        x:Name="img_grid"
        HorizontalAlignment="Stretch"
        VerticalAlignment="Center">

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Grid x:Name="img_t" Grid.Row="1">
            <Image x:Name="img" Source="{x:Bind ViewModel.FilePath, Mode=OneWay}" />
            <InkCanvas
                x:Name="img_inkcanvas"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch" />
        </Grid>
        <Grid Grid.Row="0">
            <InkToolbar
                x:Name="img_inktoolbar"
                VerticalAlignment="Top"
                TargetInkCanvas="{x:Bind img_inkcanvas}" />
        </Grid>
    </Grid>
</ContentDialog>

Code Behind:

namespace eseua.Views
{
    public sealed partial class ImageEditorDialog : ContentDialog
    {
        internal ImageEditorDialogViewModel ViewModel => DataContext as ImageEditorDialogViewModel;

        private readonly IUsageDataService _usageDataService;
        private bool isSaved = false;
        public ImageEditorDialog()
        {
            this.InitializeComponent();
            _usageDataService = ((PrismApplication)Application.Current).Container.Resolve<IUsageDataService>();
            var themeBinding = new Binding { Source = ThemeAwareHelper.Instance, Path = new PropertyPath("Theme") };
            SetBinding(RequestedThemeProperty, themeBinding);
            img_inkcanvas.InkPresenter.InputDeviceTypes =
                    Windows.UI.Core.CoreInputDeviceTypes.Mouse |
                    Windows.UI.Core.CoreInputDeviceTypes.Pen;
            this.Closing += ImageEditorDialog_Closing;

            this.PrimaryButtonClick += SaveEditedImage;
        }
        private async void SaveEditedImage(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            try
            {
                img_inktoolbar.Visibility = Visibility.Collapsed;
                img_inktoolbar.Opacity = 0;
                RenderTargetBitmap bitmap = await RenderBitmapAsync(img_t);
                await ViewModel.SaveBitmapToFile(bitmap, ViewModel.FilePath);
                sender.Hide();
            }
            finally
            {
                isSaved = true;
            }
        }
}
}

NuGet package version

WinUI 2 - Microsoft.UI.Xaml 2.8.2

Windows version

Windows 10 (22H2): Build 19045

Additional context

No response

@Marim99 Marim99 added the bug Something isn't working label Feb 19, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Feb 19, 2024
Copy link

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@bpulliam bpulliam added team-Controls Issue for the Controls team appModel-UWP Exclusive to WinUI 2 UWP apps area-InkCanvas and removed needs-triage Issue needs to be triaged by the area owners labels Feb 23, 2024
@ranjeshj ranjeshj added area-External Not owned by the WinUI team, not actionable in this repository. and removed team-Controls Issue for the Controls team labels Feb 27, 2024
@ranjeshj
Copy link
Contributor

@Marim99 thanks for the issue report. I've forwarded the issue to the appropriate team.

@llongley llongley reopened this Feb 28, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Feb 28, 2024
@daddyrex1
Copy link

in our UWP app, we have the same issue. In Windows 11 it works fine for our users.

@bpulliam bpulliam removed the needs-triage Issue needs to be triaged by the area owners label Feb 29, 2024
@bpulliam bpulliam added the needs-author-feedback Asked author to supply more information. label May 2, 2024
Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
appModel-UWP Exclusive to WinUI 2 UWP apps area-External Not owned by the WinUI team, not actionable in this repository. area-InkCanvas bug Something isn't working needs-author-feedback Asked author to supply more information. no-recent-activity
Projects
None yet
Development

No branches or pull requests

5 participants