dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7.08k stars 1.17k forks source link

Applying Style to a custom control masks control's template #1374

Closed cbaysinger closed 5 years ago

cbaysinger commented 5 years ago

The attached project does not include the custom controls. If that is need I will respond.

image

CoreApp.zip

grubioe commented 5 years ago

@cbaysinger does this reproduce in the latest daily builds? Thanks

cbaysinger commented 5 years ago

I rebuilt the project attached to the issue that was built with preview 6 using preview 7 and observed the same behavior. Have not tried the latest daily build. If there a rational for using the latest daily build I will do that based on your advice. I have been porting a large project to Core 3 and the preview 7 broke due to System.Window.Forms went missing. Question, how can I define a type double in xaml since xmlns:sys="clr-namespace:System;assembly=mscorlib" is no longer available? Thanks, cb

From: Gustavo Rubio [mailto:notifications@github.com] Sent: Friday, July 26, 2019 10:41 AM To: dotnet/wpf Cc: Craig Baysinger, Ph.D.; Mention Subject: Re: [dotnet/wpf] Applying Style to a custom control masks control's template (#1374)

@cbaysingerhttps://github.com/cbaysinger does this reproduce in the latest daily builds? Thanks

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/dotnet/wpf/issues/1374?email_source=notifications&email_token=AFJQKYBGS73EA3DBUVYIKGTQBMZLDA5CNFSM4IGVVCQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD25IGYQ#issuecomment-515539810, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFJQKYEXENZ7ZEBEWC3IVTTQBMZLDANCNFSM4IGVVCQQ.

weltkante commented 5 years ago

See #708 about the double thing. According to that issue it "should just work", but there are a few workarounds mentioned.

cbaysinger commented 5 years ago

Tried to build the little project I previously attached with the tip build Microsoft.NETCore.App\3.0.0-preview8-28376-13 and I can no longer build the project. The project creates COM interfaces using System.Activator.CreateInstance and this is no longer working. Tried the new preview8 version on the large project we are trying to port and had the same issue so at this point too much is broken to give you an answer. Regarding the Double, none of the methods in the workarounds work, but I agree it "should just work".

weltkante commented 5 years ago

@cbaysinger are you saying when you define doubles in xaml you get compiler errors, or do you mean designer errors? The example from #708 compiles and runs for me, only the designer is giving errors. You might want to hide intellisense errors from the error list in large WPF projects.

If you have a scenario where you get actual compile/runtime errors you probably should try to reduce it and open a new issue so it can be fixed.

cbaysinger commented 5 years ago

Thanks, it works just as you indicated, the designer is telling me it doesn't work but the compiler says it is ok.

SamBent commented 5 years ago

The Style issue is By Design. Your assembly NPWpfCommon.dll lacks a ThemeInfo attribute, so WPF doesn't know that it contains theme resources. (See the last section of the documentation for more info.) The local value for Style doesn't declare a value for Template; WPF would look for a value declared in theme resources, but can't find any. Therefore Template falls back to its default value - null.

A comparable .NET Framework control library behaves the same way if you remove its ThemeInfo attribute, or change both its components to ResourceLocationDictionary.None. (In VisualStudio, that's found in Properties\assemblyinfo.cs.)

cbaysinger commented 5 years ago

Thanks, that fixed the problem. I had followed a tutorial that said get rid of the AsseblyInfo.cs file because the SDK-style project would automatically create the information. This link explains how to port the file rather than get rid of it. https://docs.microsoft.com/en-us/dotnet/core/porting/wpf

From: Sam Bent [mailto:notifications@github.com] Sent: Wednesday, August 7, 2019 6:36 PM To: dotnet/wpf Cc: Craig Baysinger, Ph.D.; Mention Subject: Re: [dotnet/wpf] Applying Style to a custom control masks control's template (#1374)

The Style issue is By Design. Your assembly NPWpfCommon.dll lacks a ThemeInfo attribute, so WPF doesn't know that it contains theme resources. (See the last section of the documentationhttps://docs.microsoft.com/en-us/dotnet/framework/wpf/controls/control-authoring-overview for more info.) The local value for Style doesn't declare a value for Template; WPF would look for a value declared in theme resources, but can't find any. Therefore Template falls back to its default value - null.

A comparable .NET Framework control library behaves the same way if you remove its ThemeInfo attribute, or change both its components to ResourceLocationDictionary.None. (In VisualStudio, that's found in Properties\assemblyinfo.cs.)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/dotnet/wpf/issues/1374?email_source=notifications&email_token=AFJQKYBUFHENQKBGDHYJMM3QDNZ67A5CNFSM4IGVVCQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD32FEBY#issuecomment-519328263, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AFJQKYF3ATXCGWMUZ2TAVLLQDNZ67ANCNFSM4IGVVCQQ.