콤보 상자의 항목 목록에 문제가 있습니다. 내가 필요 특정 지점에서표시된 콤보 상자 업데이트되지 않는 항목
Public Class EDIProfile
Inherits ObservableCollection(Of EDIProfil)
:
<DockPanel x:Name="Dock_Profil" DataContext="{Binding Profile, UpdateSourceTrigger=PropertyChanged,NotifyOnSourceUpdated= True}">
<StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
<ComboBox Margin="5" Width="200" ItemsSource="{Binding}" DisplayMemberPath="ProfilName" IsSynchronizedWithCurrentItem="True"
x:Name="cmbProfil" SelectedIndex="0" ></ComboBox>
<Button Margin="5">
<StackPanel Orientation="Horizontal" >
<Image Margin="2" Stretch="None" Source="/MEC_EDINeu;component/Resources/Add24.png" />
<Label>Neues Profil</Label>
</StackPanel>
</Button>
</StackPanel>
속성 프로파일이 유형 다음 itemsource이
는 WPF는 다음과 같습니다 (파일에서) 다시로드 할 때 그들은 업데이 트를 해달라고 프로필 내용을 다시로드하십시오.
Profile.Load()
OnPropertyChanged("Profile")
이 호출됩니다. (OnPropertyChanged를가 MainWindowViewModel에 ViewModelBase.vb에 구현되고 전달)
제가 사용 MainWindow.xaml.vb 이후에 확인하는 경우 :
For Each item As EDIProfil In cmbProfil.Items
MsgBox(item.ProfilName & "__" & item.lastFA)
Next
올바른 항목이에있다.
그러나 GUI의 콤보 상자에는 여전히 이전 내용이 표시됩니다.
해결 방법은 내가 발견 (하지만 난 모든 콤보를 위해 그것을 사용 싶지 않다) : 을 (mainwindow.xaml.vb에서) 내가 그 줄을 사용하는 경우 :
cmbProfil.Items.Refresh()
의 업데이트를 콤보 상자 작업에 의해 표시되는 항목은 (그러나 야해? 그 바인딩)
나는 여기에 몇 가지 도움을받을 것을 희망하는 WPF 꽤 새로운 오전. 사전
에서
덕분에 나는 (올바른 방법 어쨌든 그것을 할 것입니다?) MainWindowViewModel의 데이터를로드 할 때 :
는Public Sub loadProfile()
'Profile.Load()
Profile.Clear()
Dim xmls As XmlSerializer = New XmlSerializer(GetType(EDIProfile))
Dim reader As New StreamReader(System.Reflection.Assembly.GetExecutingAssembly().Location.Substring(0, System.Reflection.Assembly.GetExecutingAssembly().Location.LastIndexOf("\") + 1) & "EDIProfile.xml")
Dim temp As New EDIProfile
' MsgBox("KK")
temp = xmls.Deserialize(reader)
For Each item As EDIProfil In temp
Profile.Add(item)
Next
reader.Close()
OnPropertyChanged("Profile")
End Sub
이
항목을 다시로드하기 전에 콤보 상자를 열지 않으면 제대로 표시됩니다. – BernhardAF
ComboBox를 업데이트하기 위해 어떤 종류의 멀티 스레딩을 사용하고 있습니까? – Rachel
@Rachel no no – BernhardAF