-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Implementing Tapped on Images in MarkdownTextBlock #1807
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
Changes from all commits
01892b0
8b6ab76
15eec4b
beb643c
70984c3
7ff44e8
f71765f
aea1d2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| // ****************************************************************** | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
| // This code is licensed under the MIT License (MIT). | ||
| // THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
| // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
| // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
| // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH | ||
| // THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE. | ||
| // ****************************************************************** | ||
|
|
||
| namespace Microsoft.Toolkit.Uwp.UI.Controls | ||
| { | ||
| /// <summary> | ||
| /// Return type for Clicked Event | ||
| /// </summary> | ||
| public enum LinkReturnType | ||
| { | ||
| /// <summary> | ||
| /// Returns when Link Clicked is Hyperlink | ||
| /// </summary> | ||
| Hyperlink, | ||
|
|
||
| /// <summary> | ||
| /// Returns when Link Clicked is Image | ||
| /// </summary> | ||
| Image | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ Here are some limitations you may encounter: | |
|
|
||
| - Images cannot be embedded inside a hyperlink | ||
| - All images are stretched with the same stretch value (defined by ImageStretch property) | ||
| - Relative Links & Relative Images needs to be handled manually using `LinkClicked` event. | ||
|
|
||
| ## Example Image | ||
| Note: scrolling is smooth, the gif below is not. | ||
|
|
@@ -95,7 +96,7 @@ The MarkdownTextBlock control is highly customizable to blend with any theme. Cu | |
|
|
||
| ### LinkClicked | ||
|
|
||
| Use this event to handle clicking on links for Markdown, by default the MarkdownTextBlock does not handle Clicking on Links. | ||
| Use this event to handle clicking on links or images for Markdown, by default the MarkdownTextBlock does not handle Clicking on Links or Images. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you also add a note here that taping any image will raise the LinkClicked event and with the uri of the image?Developers should use the LinkType property to decide how to handle it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. Let me know if there is anything else that i need to update. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. @WilliamABradley up to you |
||
|
|
||
| ```c# | ||
| private async void MarkdownText_LinkClicked(object sender, LinkClickedEventArgs e) | ||
|
|
@@ -107,6 +108,9 @@ private async void MarkdownText_LinkClicked(object sender, LinkClickedEventArgs | |
| } | ||
| ``` | ||
|
|
||
| > [!NOTE] | ||
| The **LinkClicked** event will be raised when either a Hyperlink or an Image is Tapped and will return element Type in **e.LinkType** on **LinkClickedEventArgs**. | ||
|
|
||
|
|
||
| ### ImageResolving | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to wrap this into a new class, or tuple or something, for Type safety.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could change it to UIElement (I think).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Image is derived from UIElement. Pretty sure Hyperlink is not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's right. I'm ok with this being how it is right now unless @WilliamABradley has any concerns