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

Implement ColorToSolidColorBrushConverter #4021

Merged
merged 2 commits into from
Feb 25, 2021

Conversation

timunie
Copy link
Collaborator

@timunie timunie commented Jan 8, 2021

Describe the changes you have made to improve this project

Implement a ColorToSolidColorBrushConverter because if we bind direct to a Color we might get binding issues.

Unit test

none

Additional context

This is an issue for some users but not for all.

@nzain can you clone my branch, attach your tracing-tool and give me a feedback if it works now for you as well? Thank you.

@seba30 if you enter a wrong color name I want to raise an error so the user gets notified that the value was wrong. So in this case the binding issue is wanted.

Closed Issues

Closes #4019

@punker76 punker76 added this to the 2.4.4 milestone Jan 8, 2021
@nzain
Copy link

nzain commented Jan 11, 2021

Unfortunately, it doesn't even build on my machine. VS complains about net4.7 SDK missing (we use 4.7.2 for years) and VS doesn't show the csproj file. Neither can I change the SDK (combobox empty and disabled). I can't test without significant time investment and, to be honest, I've dropped the idea of using MahApps after some more obstacles.

If you want to reproduce it: A simple trace listener looks like this

    public sealed class BreakDebuggerTraceListener : TraceListener
    {
        public override void Write(string message)
        {
        }

        public override void WriteLine(string message)
        {
            Debugger.Break();
        }
    }

and this is how you enable it for your application before startup:

    TraceSource dataBindingSource = PresentationTraceSources.DataBindingSource;
    dataBindingSource.Listeners.Add(new BreakDebuggerTraceListener());

@punker76
Copy link
Member

I've dropped the idea of using MahApps after some more obstacles

@nzain Can you say what other obstacles are you mean?

@nzain
Copy link

nzain commented Jan 11, 2021

@punker76 We have a large WPF desktop (framework) app and we have our own styles. Not really using themes, just basic WPF with a few changes to the defaults. We used a small fraction of Xceed's extended wpf toolkit comunity edition (one SplitButton, one ColorCanvas, a few NumericUpDown, many many BusyIndicator occurences). We always had problems with Xceed's toolkit and upgrading this nuget package always broke the AvalonDock for many versions and for different reasons every time. Thus we were stuck on a quite old version. As you may know, they've changed their license and that finally forces us to find alternatives.

We've successfully migrated to Dirkster's AvalonDock fork (works much better).
We came up with our own BusyIndicator implementation (a core component of our UI concept with many long running tasks).

I thought MahApps could fill the remaining gap (ColorPicker, SplitButton, NumericUpDown), but MahApps heavily revolves around its own style (and it doesn't match ours). Try to use the ColorPicker without MahApps styles - buttons are empty, etc. Personally, I find the NumericUpDown button order confusing (increment left, decrement right). Additionally, we can't allow editing of the alpha channel (our customers would confuse themselves) but the MahApps ColorPicker is rather new and not configurable in this aspect. I could have created a PR for the last one, but that wouldn't solve all my issues right? Don't take it too serious - I guess MahApps is great when you use it right from the start. However, it can't fill a certain gap in a large existing application.

@timunie
Copy link
Collaborator Author

timunie commented Jan 11, 2021

Hi @nzain

Thank you for providing this simple class. The debugger breaks if I enter an invalid color name but IMO this should be the case. All other binding issues seems to be resolved now.

Let me say a few words to your other issues:

  • I think you can use MahApps without using all styles, but you will need to import the used controls on your own. Moreover you may want to adopt the ControlTemplate to suit your design. MahApps is open source so you can copy the original Styles
  • NumericUpDown -> Just use SwitchUpDownButtons=true
  • I am working on hiding the Alpha-Channel as it seems to be a common need: see Feature ColorPicker should allow the hide some parts #4022

Don't take it too serious - I guess MahApps is great when you use it right from the start. However, it can't fill a certain gap in a large existing application.

Thank you for clarifying this more as it sounded like "MahApps is total mess". 👍

Happy coding
Tim

@nzain
Copy link

nzain commented Jan 11, 2021

Sorry for that! I'll keep an eye on MahApps 👍

@punker76 punker76 merged commit 8651210 into MahApps:develop Feb 25, 2021
@punker76
Copy link
Member

@timunie your changes have been merged, thanks for your contribution 👍

@timunie timunie deleted the fix/ColorPickerBindingIssues branch February 25, 2021 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

ColorCanvas has 14 Binding Expression Errors
3 participants