Skip to content

WPF Image.Source with materialDesign:PackIcon Kind="NewBox" !?!? #3236

Closed Answered by nicolaihenriksen
BRRIT2017 asked this question in Q&A
Discussion options

You must be logged in to vote

No, that will not work because PackIcon is NOT an ImageSource; it is a ContentControl. You currently - to my knowledge - have to way of getting PackIconKind converted to an ImageSource natively in the MDIX library.

And I kind of struggle to see the need for it. If you explicitly need to be able to toggle between PackIconKind and an actual image (e.g. a png source), then you could encapsulate this in a ContentControl and simply change the content based on what you want to display.

<ContentControl x:Name="ImageDisplay" />

Then in your code-behind you could set the content:

if (usePackIconKind)
{
  ImageDisplay.Content = new PackIcon { Kind = PackIconKind.GitHub };
}
else
{
  ImageDisplay.Co…

Replies: 9 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@nicolaihenriksen
Comment options

Answer selected by nicolaihenriksen
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@nicolaihenriksen
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants