Closed Drachenkaetzchen closed 4 years ago
Hard to tell without seeing a sample...
I've encountered the same issue.
Data for DataGrid
is loaded async
from DB
. During the loading the filtering popup obviously contains no items. But even after the data is loaded the popup contains no items.
The only way to fix is to select and deselect a row (lost focus)
Moment when dot
appeared
My simplified but valid sample
There are two columns with the same problem each.
First uses plain ComboBoxFilter
, second MultipleChoiceFilter
.
First uses string[]
second enum[]
.
First binds DataGridComboBoxColumn.ItemsSource
to x:Array
, second to CollectionViewSource
(which binds to view model with Enum.GetNames(typeof(Permission))
). Initially I thought the problem was in CollectionViewSource
but replacing it didn't help.
<UserControl.Resources>
<ResourceDictionary>
<x:Array x:Key="Kinds" Type="system:String">
<system:String>Admin</system:String>
<system:String>User</system:String>
<system:String>Undefined</system:String>
</x:Array>
<CollectionViewSource x:Key="Permissions" Source="{Binding Permissions}"/>
</ResourceDictionary>
</UserControl.Resources>
<DataGrid
ItemsSource="{Binding Users}"
AutoGenerateColumns="False"
dgx:DataGridFilter.IsAutoFilterEnabled="True">
<DataGrid.Columns>
<DataGridComboBoxColumn Header="Type"
SortMemberPath="kind"
ItemsSource="{Binding Source={StaticResource Kinds}}"
SelectedItemBinding="{Binding kind}">
<dgx:DataGridFilterColumn.Template>
<ControlTemplate>
<Grid d:DataContext="{d:DesignInstance dgx:DataGridFilterColumnControl}">
<Grid>
<Control Style="{DynamicResource {x:Static dgx:DataGridFilter.IconStyleKey}}"/>
<ComboBox x:Name="ComboBox"
Text="{Binding Path=Filter, UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding SourceValues}"
IsEditable="True" />
</Grid>
</Grid>
<ControlTemplate.Triggers>
<Trigger SourceName="ComboBox" Property="Text" Value="">
<Setter TargetName="ComboBox" Property="Opacity" Value="0"/>
</Trigger>
<Trigger SourceName="ComboBox" Property="Text" Value="{x:Null}">
<Setter TargetName="ComboBox" Property="Opacity" Value="0"/>
</Trigger>
<Trigger SourceName="ComboBox" Property="IsMouseOver" Value="True">
<Setter TargetName="ComboBox" Property="Opacity" Value="1"/>
</Trigger>
<Trigger SourceName="ComboBox" Property="IsFocused" Value="True">
<Setter TargetName="ComboBox" Property="Opacity" Value="1"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</dgx:DataGridFilterColumn.Template>
</DataGridComboBoxColumn>
<DataGridComboBoxColumn Header="Permission"
SortMemberPath="permission"
ItemsSource="{Binding Source={StaticResource Permissions}}"
SelectedItemBinding="{Binding permission}">
<dgx:DataGridFilterColumn.Template>
<ControlTemplate>
<local:MultipleChoiceFilter Filter="{Binding Path=Filter, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=dgx:DataGridFilterColumnControl}}" />
</ControlTemplate>
</dgx:DataGridFilterColumn.Template>
</DataGridComboBoxColumn>
</DataGrid.Columns>
</DataGrid>
</UserControl>
@Brains can you provide a PR that adds the working sample to the sample project as a new tab?
Probably that's the important part that missing if you provide only some detached xaml: "... Data for DataGrid
is loaded async
from DB
."
Sure, will try.
My model is written in F#
but I will do something similar in C#
However, I tried to make PR yesterday for my other ticket #19, but had not enough rights. Can you add me in repo settings somehow?
@Brains you have to work in your own fork, then you can create a PR from there
Finally, done #20
Maybe you should change your code to not replace the complete datasource but bind it to an observable collection that is synchronized with the items from the db - this can solve such problems.
Sorry, forgot to answer. Ok will try.
I am working with F#
, it produces a new collection each time, so I just used functional style. Will try observable collection
instead
Ok will try.
Sorry for so long delay. Just tried.
Surprisingly, but ObservableCollection
didn't help, see my commit 8a65051848bc06b0966e4c6d4ada2a135f15c20b.
Hi,
I just tried your wonderful extensions. However, when trying to use a ComboBox as seen in the example, the values aren't initially populated.
Only after I type something in the ComboBox it is populated via SelectableValues. Do you have any clue on what's going on or how I can debug this?