WPF绑定失败,当我去改变关于绑定Collection的元素的位置时

时间:2010-11-07 10:19:16

标签: wpf binding listbox wpf-4.0

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

绑定到ListBox Control,S的switch元素,绑定fail.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>

0 个答案:

没有答案