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

Customize behavior for PopupViewer - Open URI and open attachment #555

Open
bsundsbo opened this issue Feb 27, 2024 · 1 comment
Open

Customize behavior for PopupViewer - Open URI and open attachment #555

bsundsbo opened this issue Feb 27, 2024 · 1 comment
Milestone

Comments

@bsundsbo
Copy link

bsundsbo commented Feb 27, 2024

FieldsPopupElementView and AttachmentsPopupElementView has some default behavior for opening an attachment (saves to disk) and open URL in default browser. To be able to override this property, I had to create a Custom PopupViewer, custom AttachmentsPopupElementView and a custom FieldsPopupElementView. I also had to duplicate the ControlTemplate to use these popup elements templates.

Being able to override this directly on the PopupViewer, be it add behaviors to a collection, events that are routed from the PopupElements, or some other clever easy override would be excellent.

For my scenario, I wish to open URL and attachments from within my application. If I don't override this behavior directly on PopupViewer, the default behavior of default browser or save attachment would be perfectly fine.

@dotMorten
Copy link
Member

Looks like we actually added this to the MAUI version but not the WPF version:

public event EventHandler<PopupAttachmentClickedEventArgs>? PopupAttachmentClicked;
internal bool OnPopupAttachmentClicked(PopupAttachment attachment)
{
var handler = PopupAttachmentClicked;
if (handler is not null)
{
var args = new PopupAttachmentClickedEventArgs(attachment);
PopupAttachmentClicked?.Invoke(this, args);
return args.Handled;
}
return false;
}
}
/// <summary>
/// Event argument for the <see cref="PopupViewer.PopupAttachmentClicked"/> event.
/// </summary>
public class PopupAttachmentClickedEventArgs : EventArgs
{
internal PopupAttachmentClickedEventArgs(PopupAttachment attachment)
{
Attachment = attachment;
}
/// <summary>
/// Gets or sets a value indicating whether the event handler has handled the event and the default action should be prevented.
/// </summary>
public bool Handled { get; set; }
/// <summary>
/// Gets the attachment that was clicked.
/// </summary>
public PopupAttachment Attachment { get; }
}

@bsundsbo would something like this work for you?

@pMaske pMaske modified the milestone: 200.5 May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants