WPF ObservableCollection CollectionView.CurrentChanged not firing.

Posted by EL on Stack Overflow See other posts from Stack Overflow or by EL
Published on 2010-02-11T11:03:18Z Indexed on 2010/03/27 10:03 UTC
Read the original article Hit count: 1183

Filed under:
|
|

Hi folks,

I have a problem with one of my ICollectionViews. The ICollectionView's CurrentChanged event i not firing.

Please see my code below.

XAML:

            <!-- Publication -->
            <TextBlock Name="tbkPublication" Text="{x:Static abConst:Print.tbkPublicationText}" Grid.Row="0" Grid.Column="0" Margin="3" ></TextBlock>
            <ComboBox Grid.Column="1" Grid.Row="0"  Margin="3" 
                      Name="cmbPublication" BorderThickness="1" 
                      ItemsSource="{Binding Path=EnterpriseList}" DisplayMemberPath="Name" 
                      SelectedValuePath="Value" SelectedIndex="0" 
                      IsSynchronizedWithCurrentItem="True" />

            <!-- Distribution Area Region -->
            <TextBlock Name="tbkDistributionArea" Text="{x:Static abConst:Print.tbkDistributionAreaText}" Grid.Row="1" Grid.Column="0" Margin="3" ></TextBlock>
            <ComboBox Grid.Column="1" Grid.Row="1"  Margin="3" 
                      Name="cmbDistributionArea" BorderThickness="1" 
                      ItemsSource="{Binding Path=ZonesList}" 
                      DisplayMemberPath="Name" 
                      SelectedValuePath="Value" SelectedIndex="0" 
                      IsSynchronizedWithCurrentItem="True" />

AND C# (ViewModel)

    #region Properties

    public ObservableCollection<GenericNameValuePair<int, string>> EnterpriseList
    {
        get { return _abEnterpriseList; }
        set { _abEnterpriseList = value; }
    }

    public ObservableCollection<GenericNameValuePair<int, string>> ZonesList
    {
        get { return _abZonesList; }
        set
        {
            _abZonesList = value;
        }
    }

  #endregion


    private void InitCollections()
    {            
        _collectionViewEnterprise = CollectionViewSource.GetDefaultView(EnterpriseList);
        _collectionViewZone = CollectionViewSource.GetDefaultView(ZonesList);

        //Replace
        if(_collectionViewEnterprise == null)
            throw new NullReferenceException("Enterprise collectionView is null.");

        if (_collectionViewZone == null)
            throw new NullReferenceException("Zone collectionView is null.");

        _collectionViewEnterprise.CurrentChanged += new EventHandler(OnCollectionViewEnterpriseCurrentChanged);
        _collectionViewZone.CurrentChanged += new EventHandler(OnCollectionViewZoneCurrentChanged);
    }

Please help. Thanks in advance.

© Stack Overflow or respective owner

Related posts about c#

Related posts about wpf