WPF Image.Source with materialDesign:PackIcon Kind="NewBox" !?!? #3236
-
Hi, For example: Am I missing the connection somehow? Best regard Bernd |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 2 replies
-
@BRRIT2017 Is there a particular reason you want it as an Instead of your |
Beta Was this translation helpful? Give feedback.
-
This is my image in WPF:
|
Beta Was this translation helpful? Give feedback.
-
@BRRIT2017 Ok so it seems like you want an image (e.g. Images/gnome-help.png) in some cases, and then to use a I don't think the actual |
Beta Was this translation helpful? Give feedback.
-
The image provided is just an example The MaterialDesign can also be used dynamically as a stack panel or button. Sample SpackPalnel with Material Design:
|
Beta Was this translation helpful? Give feedback.
-
@BRRIT2017 Ok. Still not 100% sure I understand what it is you want. But here is what I think you're asking for: Q: How can I dynamically change the "icon" in code-behind? If that is the case, we can just use the code you provided above: <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Height="82" Width="82">
<materialDesign:PackIcon x:Name="MyPackIcon" Kind="NewBox" Foreground="#FF2828B0" Width="72" Height="80" HorizontalAlignment="Center" VerticalAlignment="Center" Focusable="False" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" IsEnabled="False" />
</StackPanel> In the above I have added the name "MyPackIcon" to the MyPackIcon.Kind = PackIconKind.GitHub; That will change the icon from |
Beta Was this translation helpful? Give feedback.
-
This will not working... eg.: |
Beta Was this translation helpful? Give feedback.
-
I change not this in XAML: |
Beta Was this translation helpful? Give feedback.
-
Here is the Correct Error Message: |
Beta Was this translation helpful? Give feedback.
-
I got it :-) |
Beta Was this translation helpful? Give feedback.
No, that will not work because
PackIcon
is NOT anImageSource
; it is aContentControl
. You currently - to my knowledge - have to way of gettingPackIconKind
converted to anImageSource
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 aContentControl
and simply change the content based on what you want to display.Then in your code-behind you could set the content: