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

Simplify CellTemplate in XAML #2147

Open
Symbai opened this issue Nov 2, 2019 · 3 comments
Open

Simplify CellTemplate in XAML #2147

Symbai opened this issue Nov 2, 2019 · 3 comments
Labels
Enhancement Requested Product code improvement that does NOT require public API changes/additions
Milestone

Comments

@Symbai
Copy link
Contributor

Symbai commented Nov 2, 2019

Would it be possible to automatically assume the content of CellTemplate is a DataTemplate? I think this is what is the case for 95%. Honestly I haven't seen any other case yet.

I.e. instead of this:

<DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
        <TextBlock />
    </DataTemplate>
</DataGridTemplateColumn.CellTemplate>

You can write:

<DataGridTemplateColumn.CellTemplate>
    <TextBlock />
</DataGridTemplateColumn.CellTemplate>

Unless specified otherwise.

@weltkante
Copy link

weltkante commented Nov 4, 2019

I don't think the XAML parser allows leaving out DataTemplate. Leaving it out would mean you are assigning TextBlock (or rather, arbitrary UIElements) to the CellTemplate property directly.

Also you are going to confuse the designer even more than it is already, since DataTemplate is an indicator for a context switch (actually you often place a DataType attribute on it to help the designer figure out its intellisense). Removing DataTemplate and making it an implicit context switch in the CellTemplate property is going to be really hard to support in design time intellisense. When you want to put bindings on your UIElements in the CellTemplate the designer won't have any clue you've switched context and it needs to show different intellisense.

@Symbai
Copy link
Contributor Author

Symbai commented Nov 4, 2019

I don't think the XAML parser allows leaving out DataTemplate. Leaving it out would mean you are assigning TextBlock (or rather, arbitrary UIElements) to the CellTemplate property directly.

I think you misunderstood my request, or I am misunderstanding your answer.

Anyway like I said, the parser / designer /whatssover can automatically add a datatemplate when its missing. I'm not going to remove the datatemplate. I am going to remove the need of developers having to add/type these extra lines in xaml for 95% of all cases and let WPF do this job instead.

Similar as #84

@weltkante
Copy link

weltkante commented Nov 4, 2019

Nope, not similar at all. #84 fits into the existing parser/designer implementation, it is just marking the property as default. This doesn't work here for the reasons I described above, #84 would correspond to removing DataGridTemplateColumn.CellTemplate tag not the DataTemplate tag.

I'm not saying its impossible to implement your suggestion but it would require changing how the parser/designer works currently.

@arpitmathur arpitmathur added the Enhancement Requested Product code improvement that does NOT require public API changes/additions label Nov 5, 2019
@arpitmathur arpitmathur added this to the Future milestone Nov 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Requested Product code improvement that does NOT require public API changes/additions
Projects
None yet
Development

No branches or pull requests

3 participants