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

.Net MAUI Binding inside CollectionView Inside Datatemplate Inside ResourceDictionary #23350

Open
trashhacker opened this issue Jun 28, 2024 · 3 comments
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView platform/windows 🪟 s/needs-attention Issue has more information and needs another look t/bug Something isn't working
Milestone

Comments

@trashhacker
Copy link

trashhacker commented Jun 28, 2024

Description

<DataTemplate x:Key="reminderpresentertemplate" x:DataType="{x:Type vmpresenter:ReminderPresenterViewModel}">
    <Grid>
        <syncfusiondatagrid:SfDataGrid ItemsSource="{Binding Reminders}" SelectedRow="{Binding Selected}" AutoGenerateColumnsMode="None" AllowEditing="False"
                           AllowDeleting="False" AllowDraggingColumn="False"  ColumnWidthMode="Fill" BackgroundColor="White">
            <syncfusiondatagrid:SfDataGrid.Columns>
                <syncfusiondatagrid:DataGridTextColumn HeaderText="{DynamicResource name}" DisplayBinding="{Binding Name}"/>
                <syncfusiondatagrid:DataGridTextColumn HeaderText="{DynamicResource started}" DisplayBinding="{Binding Started}"/>
                <syncfusiondatagrid:DataGridTextColumn HeaderText="{DynamicResource appointment}" DisplayBinding="{Binding Appointment}"/>
                <syncfusiondatagrid:DataGridTemplateColumn HeaderText="{DynamicResource remaining}" >
                    <syncfusiondatagrid:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate x:DataType="{x:Type vm:ReminderViewModel}">
                            <syncprogressbar:SfLinearProgressBar  />
                            <!--Progress="{Binding Progress, Mode=OneWay}" Maximum="1" Minimum="0" Background="Transparent"
                                           ProgressFill="{Binding Expired, Converter={StaticResource reminderprogressconverter}}"-->
                        </DataTemplate>
                    </syncfusiondatagrid:DataGridTemplateColumn.CellTemplate>
                </syncfusiondatagrid:DataGridTemplateColumn>
            </syncfusiondatagrid:SfDataGrid.Columns>

        </syncfusiondatagrid:SfDataGrid>
    </Grid>
</DataTemplate>
  1. If i use the x:DataType on the CollectinView.Itemtemplate:
    the debbuger (Error Analysier at Compliletime) says that the binding has a wrong string format

  2. if i remove it:
    it says the property is not found... again at compile time

but i tried it with an converter and the correct value is passed but visual studio marks it as an error

Steps to Reproduce

create a Template in a ResourceDictionary
use this contentcontrol for dynamically selecting the template
populate a list in the template and bind it to the collection
create an itemtemplate for the collection

namespace Intrinsic.Base
{
    public class ContentControl : ContentView
    {
    public static readonly BindableProperty DataTemplateSelectorProperty = BindableProperty.Create(nameof(DataTemplateSelector), typeof(DataTemplateSelector), typeof(ContentControl), propertyChanged: DataTemplateSelectorPropertyChanged);
    private static void DataTemplateSelectorPropertyChanged(BindableObject bindable, object oldValue, object newValue)
    {
        if (bindable is ContentControl control)
            control.GenerateContent();
    }

    public static readonly BindableProperty ItemTemplateProperty = BindableProperty.Create(nameof(ItemTemplate), typeof(DataTemplate), typeof(ContentControl), propertyChanged: ItemTemplatePropertyChanged);
    private static void ItemTemplatePropertyChanged(BindableObject bindable, object oldValue, object newValue)
    {
        if (bindable is ContentControl control)
            control.GenerateContent();
    }

    public static readonly BindableProperty ItemProperty = BindableProperty.Create(nameof(Item), typeof(object), typeof(ContentControl), propertyChanged: ItemPropertyChanged);
    private static void ItemPropertyChanged(BindableObject bindable, object oldValue, object newValue)
    {
        if (bindable is ContentControl control)
            control.GenerateContent();
    }

    public DataTemplateSelector DataTemplateSelector
    {
        get => (DataTemplateSelector)GetValue(DataTemplateSelectorProperty);
        set => SetValue(DataTemplateSelectorProperty, value);
    }
    public DataTemplate ItemTemplate
    {
        get => (DataTemplate)GetValue(ItemTemplateProperty);
        set => SetValue(ItemTemplateProperty, value);
    }
    public object Item
    {
        get => GetValue(ItemProperty);
        set => SetValue(ItemProperty, value);
    }
    private void GenerateContent()
    {
        if (Item != null && (DataTemplateSelector?.SelectTemplate(Item, this) ?? ItemTemplate) is DataTemplate template)
        {
            template.SetValue(BindingContextProperty, Item);
            if (template.CreateContent() is View view)
            {
                Content = view;
                return;
            }
        }

        Content = null;
        return;
        }
    }
}

Link to public reproduction project repository

No response

Version with bug

Unknown/Other

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

8.0.40 /8.0.100

Did you find any workaround?

No response

Relevant log output

No response

@trashhacker trashhacker added the t/bug Something isn't working label Jun 28, 2024
Copy link
Contributor

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@trashhacker
Copy link
Author

ok i have checked the other issues... its not a duplicate, its kinda related ok...
but this is a bug that has nothing to to with the sugested issues
so pls can i have a visite or an answere from your code gurus :D

@PureWeen PureWeen changed the title .Net MAUI Binidng inside Collectinview Inside Datatemplate Inside ResourceDictionary .Net MAUI Binding inside CollectionView Inside Datatemplate Inside ResourceDictionary Jul 11, 2024
@PureWeen PureWeen added s/needs-repro Attach a solution or code which reproduces the issue area-controls-collectionview CollectionView, CarouselView, IndicatorView labels Jul 11, 2024
@PureWeen PureWeen added this to the Backlog milestone Jul 11, 2024
@trashhacker
Copy link
Author

trashhacker commented Jul 14, 2024

yea code gurus come from heaven to help me :D
https://github.com/trashhacker/ReproBindingError

im sorry i did not read your guidlines for repos (:
hope its ok

and yea its not only collectionview its more the datatemplate inside the what ever collection -- my bad sorry

if you remove

                        <Label Text="{Binding Identifier}"/>
                        <Label Text="{Binding Description}"/>

it will compile and if u copy and past it while debugging it will work too

@dotnet-policy-service dotnet-policy-service bot added s/needs-attention Issue has more information and needs another look and removed s/needs-repro Attach a solution or code which reproduces the issue labels Jul 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView platform/windows 🪟 s/needs-attention Issue has more information and needs another look t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants