Giter Site home page Giter Site logo

Comments (16)

 avatar commented on May 4, 2024

I think the 'fault' is with MetroImage, which is used internally by AppBarButton. Frankly, I'm not a big fan of either, and they were submissions by somebody else.

Personally, I use the button/rectangle trick because it just works easier.

from mahapps.metro.

AndrewWiles avatar AndrewWiles commented on May 4, 2024

Thanks Paul

Do you know who pushed the feature. I think it would be good to either get them to fix it or have it withdrawn....

from mahapps.metro.

 avatar commented on May 4, 2024

You're right Andrew, it either needs to work or not be there since it can't be used "by itself". I think this was introduced by @JakeGinnivan, I'll double check with him today.

from mahapps.metro.

 avatar commented on May 4, 2024

While it turns out AppBarButton is using the Rectangle/Visual thing, this bug is also present in MetroImage

from mahapps.metro.

AndrewWiles avatar AndrewWiles commented on May 4, 2024

I don't know if it will help Jake but when I was debugging through the code I noticed that the "set" for the MetroImage attribute was not being called.

from mahapps.metro.

jaohaohsuan avatar jaohaohsuan commented on May 4, 2024

another thing is when use the button/rectangle the icon of color can not change with button foreground

from mahapps.metro.

sirWest avatar sirWest commented on May 4, 2024

@jaohaohsuan this makes sense at the colors are defined already in the Resources library and not dynamically with button/rectangle style. This can be changed however currently it seems for me that the not-loading-issue might be related to the canvas being served from outer resource library in general. I have messed with this a while now and the only working solution has been to copy the canvas locally to rectangle fill tag. We'll see.......

from mahapps.metro.

nCubed avatar nCubed commented on May 4, 2024

I was able to work around this issue by defining the Colours.xaml style in both the App.xaml and the Window using the MetroImage, Not sure why this works, but it does. Dynamic theme changes works with this as well.

App.xaml

<ResourceDictionary>
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary x:Name="MetroIcons" Source="pack://application:,,,/YourNameSpace;component/Resources/Icons.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedSingleRowTabControl.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" />
    </ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

Window.xaml

<Window.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colours.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
            <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Window.Resources>

from mahapps.metro.

sirWest avatar sirWest commented on May 4, 2024

@nCubed I don't think this is a workaround at all - all Canvas elements use DynamicResource colors which they don't have direct access to, so this must be referenced by the root classes of your project to provide the necessary link. I tried also to add the Colours.xaml reference to the Icons.xaml resources but no luck - so it must be done on the root level of the referencing project. This makes some sense to me at least :)

from mahapps.metro.

nCubed avatar nCubed commented on May 4, 2024

@sirWest - you are correct, I should have been more explicit. You need to include the relevant color schemes as in my example, not just Colours.xaml.

However, after further testing, the dynamic theme changing doesn't work quite as expected in my example. I believe the complete resolution is to duplicate all the xaml color files in the Window and the App.xaml.

Not the greatest of resolutions. May just be a case where using the basic button styling in lieu of the AppBarButton is the preferred method.

from mahapps.metro.

sirWest avatar sirWest commented on May 4, 2024

@nCubed On the demo app all themes are working for me when just including the Colours.xaml in App resources. What cases aren't working and what could be the differences in the surrounding app's environment?

from mahapps.metro.

nCubed avatar nCubed commented on May 4, 2024

@sirWest - sorry for the delayed response; been tied up. I'll test this further tomorrow and try to come up with the cases that are not working.

from mahapps.metro.

nCubed avatar nCubed commented on May 4, 2024

@sirWest - I threw together a demo app and re-tested everything. Indeed the work-around for this issue does appear to be to place Colours.xaml in the app.config.

I spent a bit of time on the source for AppBarButton, but came up empty as to what the underlying issue is.

from mahapps.metro.

sirWest avatar sirWest commented on May 4, 2024

@nCubed I have fiddled with this issue also for a longer while without any other results what would indicate that something is actually broken. This can possibly only be related to some broken resource sharing. I just didn't think that such a simple fix will do it :)

from mahapps.metro.

JakeGinnivan avatar JakeGinnivan commented on May 4, 2024

Glad you guys are finding it difficult to pin down, I have also looked over the source of this stuff, it was supposed to make it easier and less xaml to use the images than the rectangle approach. Am sorry it has caused all these issues, but it looks like issues inside WPF's resource resolution which is the underlying cause of these issues =( I am short of time which is why I havenโ€™t been posting much, but am following this issue with interest =)

Cheers,
Jake

-----Original Message-----
From: Tanel T [mailto:[email protected]]
Sent: Monday, 21 May 2012 11:54 PM
To: Jake Ginnivan
Subject: Re: [MahApps.Metro] AppBarButton does not load image (#41)

@nCubed I have fiddled with this issue also for a longer while without any other results what would indicate that something is actually broken. This can possibly only be related to some broken resource sharing. I just didn't think that such a simple fix will do it :)


Reply to this email directly or view it on GitHub:
#41 (comment)

from mahapps.metro.

 avatar commented on May 4, 2024

Since we've been unable to solve this, AppBarButton will be marked as Obsolete for 0.9, and removed by 1.0

from mahapps.metro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.