1
public ObservableCollection<string> S { get; set; }

S绑定到ListBox控件,切换S的元素,绑定失败。ListBox当前项如下:

 public string CurrentItem 
    {
        get
        {
            return m_currentitem;
        }
        set
        {
            m_currentitem = value;
            int index = S.IndexOf(value);
            if (index >= 5)
            {
                string s = S[4];
                S[4]= m_currentitem;
                m_currentitem = s;
            }
        }
    }
<ListBox ItemsSource="{Binding S}" SelectedItem="{Binding CurrentItem,Mode=TwoWay}" >
                <ListBox.ItemsPanel>
                    <ItemsPanelTemplate>
                        <UniformGrid Columns="5" Loaded="UniformGrid_Loaded"></UniformGrid>
                    </ItemsPanelTemplate>
                </ListBox.ItemsPanel>
            </ListBox>
4

0 回答 0