question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support nested types in DataTemplate.DataType

See original GitHub issue

Currently TypeResolver goes crazy - raises exception (for 0.8.x version [clarification: only for F# modules that don’t have namespace]) and gives error in compile time from the master branch.

Just to show some sample. This kind of code is perfectly valid in WPF:

        <ItemsControl ItemsSource="{Binding Items}">
            <ItemsControl.ItemTemplate>
                <DataTemplate DataType="{x:Type local:SomeClass+Data}">
                    <TextBlock Text="{Binding Value}" />
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            DataContext = this;
        }

        public IEnumerable<Data> Items { get => Enumerable.Range(0, 10).Select(_ => new Data()); }
    }

    public static class SomeClass
    {
        public class Data
        {
            public string Value { get; } = "Hello World";
        }
    }

While this is a rare use-case for C# in F# world it’s common. Instead (or additional to) of using namespace, types are grouped in modules, like this:

module Test = 
    type SomeType = { Id : int; Value : string }

So I think it would be very nice to have support for this scenario.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:5
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
grokyscommented, Jan 13, 2022

Investigating this now, looks like this works fine in unit tests, which makes it harder to fix…

Update: yep, seems to be our Mono.Cecil backend that’s not handling this correctly.

0reactions
BAndysccommented, Dec 19, 2021

+1, it prevents from using CompiledBindings in few places 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

wpf - Can a DataTemplate be tied to a nested class?
In XAML, I'm trying to map a DataTemplate to types B and C, but I cannot fully qualify the nested class name. <ItemsControl...
Read more >
Xamarin.Forms xaml DataType pointing to nested class
Forms xaml DataType pointing to nested class. Data context is not correctly resolved when using a nested class. <DataTemplate ...
Read more >
How to bind to nested properties (generated from JSON) in ...
I need some advice regarding binding to nested properties in generated class from JSON using Json2C#. So I'm using firebase cloud functions ...
Read more >
How to generate tree like diagram with nested objects in WPF
Nested business objects are directly set as ItemSource and a tree diagram is generated automatically by using the HierarchicalDataTemplate. The following code ...
Read more >
Problem with nested hierarchy in gridView in UI for WPF
My goal is to show a list of Divisions in a gridView, each division has teams, and each team has some employees. I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found