Support nested types in DataTemplate.DataType
See original GitHub issueCurrently 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:
- Created 4 years ago
- Reactions:5
- Comments:5 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
+1, it prevents from using CompiledBindings in few places 😦