question

MageshSankar-5062 avatar image
MageshSankar-5062 asked ·

Custom Control edit template cause compilation failure in Visual Studio 2019 (version 16.7 Preview 2)


In Visual Studio 2019 version 16.7 Preview 2, while try to edit the template of my custom control using Edit Template option in designer which causes compilation failure due to empty properties fields generated. Please find the code genereate details.


Code in our source side

<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="HorizontalContentAlignment" Value="{x:Static HorizontalAlignment.Center}" />



Code generated while edit template


<Setter Property="FocusVisualStyle">
<Setter.Value>
<Null/>
</Setter.Value>
</Setter>

<Setter Property="HorizontalContentAlignment">
<Setter.Value>
<Static/>
</Setter.Value>
</Setter>

The issue reproduce only in Preview version and it working fine previous version.


Project Framework : 4.6v

Error : Severity Code Description Project File Line Suppression State
Error The tag 'Static' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'. Line 85 Position 22. ControlTesting MainWindow.xaml 85



Please suggest any solution to fix this.

Thanks



















































windows-wpf
7 comments
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I'm also facing same problem. I've created simple custom library and custom control to demonstrate the issue.

Sample: https://drive.google.com/file/d/1sJG2CPzHuw6r5LwH06vm77eVmgY49eRX/view?usp=sharing

In additional am facing, that the AutomationProperty name is replaced with x:Name of the control while generating template.

Style will be generated properly if the control source has been attached to the application.

0 Votes 0 · ·

I can't reproduce your issue in my Visual Studio 16.7 preview 2 with .framework4.6. Here is my option for generating code in edit template. Did I miss some option for your issue?
9832-1.png

and the result image is:

9852-2.png


0 Votes 0 · ·
1.png (37.4 KiB)
2.png (92.7 KiB)

@DaisyTian-MSFT check once did you enabled preview features in you Visual STudio


9680-preview.png


0 Votes 0 · ·
preview.png (130 B)

@DaisyTian-MSFT Check once , whether you enabled preview features options in your Visual Studio. The reported issue reproduce only you enabled preview features


9856-preview.png


0 Votes 0 · ·
preview.png (588.3 KiB)

I still can't reproduce the issue with it checked, could you show me the detailed steps to reproduce the issue?

0 Votes 0 · ·

@DaisyTian-MSFT , attached reproduce sample in my post. Can you check that?


0 Votes 0 · ·

I'm also facing this issue. Additionally, i'm facing the issue the attached properties are not generated when copying the template. For example, It generates <setter value="false"/> instead of <setter property="Stylus.IsFlicksEnabled" value="false"/>.









0 Votes 0 · ·

1 Answer

LeonLaude avatar image
LeonLaude answered ·

Hi,

Visual Studio is currently not supported in the Q&A forums, the supported products are listed over here https://docs.microsoft.com/en-us/answers/products (more to be added later on).

You can ask the experts in the dedicated Visual Studio forum over here:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?category=visualstudio

(Please don't forget to accept helpful replies as answer)

Best regards,
Leon

Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.