Open Nikhilthambi opened 1 year ago
is the ComboBox bound to anything in the ViewModel?
yes the value bound in the viewmodel.
In that case that shouldn't happen. However, current supported version is 11.0.4, so unlikely a bug in v0.10 gets fixed. I see two options for now:
I am seeing an issue that I think is related. Selected item in combobox is null - if I scroll in my datagrid or resize the window then the combox selected value value shows up. This is with 11.0.4.
and after manipulating window size a few times.
I'll try to look into it here to see if I can find anything.
@ykarpeev please file a minimal sample to reproduce.
I am seeing an issue that I think is related. Selected item in combobox is null - if I scroll in my datagrid or resize the window then the combox selected value value shows up. This is with 11.0.4.
and after manipulating window size a few times.
I'll try to look into it here to see if I can find anything.
I am also getting something similar issue, my case when I switch the tab and I tried with this 11.0.2 version.
In that case that shouldn't happen. However, current supported version is 11.0.4, so unlikely a bug in v0.10 gets fixed. I see two options for now:
- Enable compiled bindings (if not yet) to debug binding issues better. If that doesn't help,
- try DataGridTemplateColumn
I tried both solution but still getting the same issue
@Nikhilthambi if you have a minimal sample to reproduce, please share it.
Here is a minimal sample.
https://github.com/ykarpeev/avaloniadatagridrepro
For me, on resizing the window to a few pixels wide then resizing back a couple of times will make some of the selected items show up.
@ykarpeev found your issue. You are binding to $parent[]
but DataGridColumn cannot resolve it. So better to bind to named element here. Set x:Name
to the window or DataGrid and bind to it via #root.DataContext...
Sent a PR: https://github.com/ykarpeev/avaloniadatagridrepro/pull/1
Thank you. That solves part of my issue, but I think mine must be separate from the parent and is related to the fact that my datagrid is in a user control. If they are using a usercontrol maybe it is still the same.
Switching between tabs I see new errors
Binding]Error in binding to 'datagridrepro.Views.UserControl1'.'DataContext': 'Null value in expression '{empty}' at ''.'(UserControl1 #33189039) [Binding]Error in binding to 'Avalonia.Controls.ComboBox'.'ItemsSource': 'Null value in expression '{empty}' at '$parent[UserControl, 0].DataContext'.'(ComboBox #50685404) [Binding]Error in binding to 'Avalonia.Controls.ComboBox'.'ItemsSource': 'Null value in expression '{empty}' at '$parent[UserControl, 0].DataContext'.'(ComboBox #41270904) [Binding]Error in binding to 'Avalonia.Controls.ComboBox'.'ItemsSource': 'Null value in expression '{empty}' at '$parent[UserControl, 0].DataContext'.'(ComboBox #51461341)
https://github.com/AvaloniaUI/Avalonia/assets/6986975/178aee8a-ce9c-4ead-881a-c1826b129013
I fixed this by wrapping the usercontrol in a contentcontrol..
_<ContentControl>
<local:UserControl1 DataContext="{Binding}" />
</ContentControl>_
@ykarpeev you can also give the DataGrid
or UserControl
or whatever a name and use the same strategy.
Describe the bug I have a Datagrid and inside this Datagrid there is one Combobox. When I switch the tab the Combobox SelectedItem is empty automatically without any action.
To Reproduce Steps to reproduce the behavior:
Expected behavior To have the combobox retain their values after switching tabs (When change the Tab somehow the SelectedItem property value is set to null. This should not happen)
Screenshots Before switching tabs:
After switching tab:
Desktop (please complete the following information):
Additional context there is already a closed ticket same scenario like this but the issue is still there. Please find the related closed bug ticket: https://github.com/AvaloniaUI/Avalonia/issues/5661
Could you please check and fix this issue?
Thanks