Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Trying to implement showing multiple selections on ListView

$
0
0

This is the class for the objects in the list (At least the relevant portions)
`
public class Icd10Code : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
if (PropertyChanged == null)
return;

        PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }
    private bool _IsSelected;
    public bool IsSelected 
    { 
        get { return _IsSelected; }
        set 
        {
            _IsSelected = value;
            OnPropertyChanged ("ShowSelected");
        } 
    }
    public string ShowSelected
    {
        get
        { 
            if (IsSelected)
                return "Blue";
            else
                return "Black";
        }
    }
}

`

< Label TextColor="{Binding ShowSelected}" LineBreakMode="NoWrap" FontSize="14" x:Name="CodeLabel" Text="{Binding Code}" />
< Label TextColor="{Binding ShowSelected}" FontSize="14" x:Name="DescriptionLabel" Text="{Binding ShortDescription}" LineBreakMode="WordWrap" />

I know the binding is working because the text shows. The font color never changes however when selected
`
public async void OnSelection (object sender, SelectedItemChangedEventArgs e)
{

        Icd10Code code = (Icd10Code)e.SelectedItem;
        if (code.HasChildCodes) 
        {
            //This fetches a new list of codes from the server.
            var codes = await Icd10CodeService.Search (code.ID, "");
            this.codeArray.Add (codes);
            this.arrayIndex++;
            SearchList.ItemsSource = null;
            SearchList.ItemsSource = this.CurrentCodes;
            UpButton.IsVisible = true;

        } 
        else 
        {
            if (selectedCodes.Contains (code)) 
            {
                selectedCodes.Remove (code);
                code.IsSelected = false;
            } 
            else 
            {
                selectedCodes.Add (code);
                code.IsSelected = true;
            }
        }
    }

`


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>