Stephen

Stephen

  • NA
  • 7
  • 1.9k

wpf databound datagrid - how to prevent duplications Pin

Jul 24 2013 11:49 AM
 Using WPF, I have a datagrid, databound to a observable collection/collectionviewsource.
 
Say my grid has only 1 column ("NAME").
How can I make sure I only populate the grid with NO duplications.
 
I've looked at multivalue converters... validationRules.
 
Either way, I don't know how to display values with no duplications.
 
Any assistance would be GREATLY appreciated.
Thanks
 
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Market">
                                <DataGridTextColumn.Binding>
                                    <MultiBinding Converter="{StaticResource ResourceKey=myConverter}">
                                        <Binding Path="tMarketName" UpdateSourceTrigger="PropertyChanged">
                                            <Binding.ValidationRules>
                                                <local:UniqueNameValidation CurrentCollection="{StaticResource ResourceKey=ViewSource}"/>
                                            </Binding.ValidationRules>    
                                        </Binding>
                                        <Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type DataGrid}, AncestorLevel=1}"/>
                                        <Binding Path="."/>
                                        <Binding Source="{StaticResource ResourceKey=MyData}"/>
                                    </MultiBinding>
                                </DataGridTextColumn.Binding>
                            </DataGridTextColumn>

Answers (7)