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

DataGrid not propagating the changes to its child DataGridTemplateColumn elements #18020

Open
LazaroOnline opened this issue Jan 22, 2025 · 1 comment
Labels

Comments

@LazaroOnline
Copy link

Describe the bug

In a DataGrid, if you add an item to it,
that has a sub list property List<string> MyUrlList {get; set;}
with some urls setted and binded to a
DataGridTemplateColumn > SplitButton > MenuFlyout > ItemsSource,
it loads the row correctly, and the SplitButton.Flyout shows the list of 2 items.

BUT, if you remove the row item from the DataGrid and replace it with another one,
the first row in the DataGrid updates correctly each cell except for
the SplitButton.Flyout that is still pointing
to the list of the first element ever loaded in that position of the DataGrid,
instead of refreshing it.

DataGrid got the update notification and updated the rest of the values,
but DataGrid didn't notify the child SplitButton.Flyout to update it's ItemsSource.

This is a nasty bug because everything looks like it works but then the links and data inside are referencing another person/object!

To Reproduce

AXAML Example:

<DataGrid ItemsSource="{Binding MyList}" AutoGenerateColumns="False">
	<DataGrid.Columns>
		<DataGridTemplateColumn Header="Actions">
			<DataGridTemplateColumn.CellTemplate>
				<DataTemplate DataType="model:MyModel">
					<SplitButton Content="My Url List" Command="{Binding OpenMyMainUrl}"
						<SplitButton.Flyout>
							<MenuFlyout ItemsSource="{Binding MyUrlList}">
								<MenuFlyout.ItemContainerTheme>
									<ControlTheme TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}" x:DataType="model:Link">
										<Setter Property="Header" Value="{Binding MyText}"/>
										<Setter Property="Command" Value="{Binding OpenUrl}"/>
									</ControlTheme>
								</MenuFlyout.ItemContainerTheme>
							</MenuFlyout>
						</SplitButton.Flyout>
					</SplitButton>
				</DataTemplate>
			</DataGridTemplateColumn.CellTemplate>
		</DataGridTemplateColumn>
	</DataGrid.Columns>
</DataGrid>

Expected behavior

No response

Avalonia version

11.2.3

OS

Windows

Additional context

No response

@LazaroOnline
Copy link
Author

Another way to put it into words is that the Dynamic MenuFlyout "popup" doesnt get refreshed when it is placed inside a DataGrid's row that has loaded other rows before, then removed the rows and then added new rows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant