ben burada yanlış yapıyorum emin değilim mülkiyet değişikliği ile güncellenir değil (bir değer) HashTable'dan. aşağıdaki gibiWPF UI <p></p> Birisi bir "PARTNUMBER" silmenize olanak sağlayan bir yöntem olan özel bir HashTable var ...
silme yöntemi: Ben arayüzüne Hashtable altında yatan değerleri bağlama am
class COSC202HashTable : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
//....
private List<int> underlyingList;
//...
public List<int> HashList { get { return underlyingList; } }
public void Delete(int partNumber)
{
string theAlgoritnm = Algorithm;
if (String.Compare(theAlgoritnm, "Modulo Division") == 0 && String.Compare(Probe, "Linear Collision Resolution") == 0)
{
LinearModularDivision(partNumber, false);
}
if (String.Compare(theAlgoritnm, "Modulo Division") == 0 && String.Compare(Probe, "Key Offset Collision Resolution") == 0)
{
KeyOffsetModularDivision(partNumber, false);
}
if (String.Compare(theAlgoritnm, "Pseudorandom") == 0)
{
Pseudorandom(partNumber, false);
}
if (String.Compare(theAlgoritnm, "Rotation") == 0)
{
Rotation(partNumber, false);
}
NotifyPropertyChanged("HashList");
}
//.......
private void NotifyPropertyChanged(String info)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
}
; ancak bir değer silindikten sonra UI güncellenmez.
<Window.Resources>
<COSC202:COSC202HashTable x:Name="TheHashTable" x:Key="TheHashTable" PropertyChanged="TheHashTable_PropertyChanged"></COSC202:COSC202HashTable>
</Window.Resources>
<ListView x:Name="HashResults" Height="32" Width="1200" Margin="10" HorizontalAlignment="Right"
DataContext="{Binding Source={StaticResource TheHashTable}}" ItemsSource="{Binding Path=HashList}" HorizontalContentAlignment="Left">
<ListView.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,2">
<GradientStop Color="#FF000000" Offset="0"></GradientStop>
<GradientStop Color="DarkBlue" Offset="1"></GradientStop>
</LinearGradientBrush>
</ListView.Background>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" >
<TextBlock Text="{Binding Path=.}" FontSize="11" Foreground="Azure" VerticalAlignment="Top" ></TextBlock>
<Label Content="|" VerticalAlignment="Top" FontSize="5"></Label>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Bunun içinde öğeyi silmek için aradım kodu: Ben
Bu benim WPF UI için sahip biçimlendirme olduğunu ... yazım vb ile herhangi bir sorun olmadığından emin yaptı Hash düğmesine basıldıktan sonra tıklatın:
private void DeleteItem_Click(object sender, RoutedEventArgs e)
{
Object item = HashResults.SelectedItem;
COSC202HashTable theHashTable = (COSC202HashTable)this.Resources["TheHashTable"];
if (theHashTable != null && item != null)
{
theHashTable.Delete((int)item);
}
HashResults.SelectedIndex = -1;
}
Neyi yanlış yapıyorum?
sayesinde
-Frinny
Sorunuzla alakasız, ancak neden '==' yerine 'String.Compare()' kullanıyorsunuz? – svick
Çünkü böyle şeyler yapmak için kullanıyorum. Esas olarak VB.NET ile çalışıyorum ve bunu dizeleri karşılaştırmak için en iyi yol olarak buldum. – Frinavale