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

Comments

@Symbai
Copy link

@Symbai 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

This comment has been minimized.

Copy link

@weltkante 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

This comment has been minimized.

Copy link
Author

@Symbai 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

This comment has been minimized.

Copy link

@weltkante 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 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
Projects
None yet
3 participants
You can’t perform that action at this time.