0
私のGird内でComboBoxを更新したいと考えています。私は何らかのイベントシステムが必要だと思っています。DataContext:comboBoxのItemSourceを更新する
次のように私はそれをバインドされました:次のように
<ComboBox Name="ScreenLocations" Grid.Row="1" Margin="0,0,0,175" ItemsSource="{Binding Path=CurrentPlayer.CurrentLocation.CurrentDirections}" DisplayMemberPath="Name" SelectedValuePath="Name" SelectedValue="{Binding Path= Location}"/>
私xaml.csは次のとおりです。
public partial class MainWindow : Window
{
GameSession _gameSession;
public MainWindow()
{
InitializeComponent();
_gameSession = new GameSession();
DataContext = _gameSession;
}
}
私はCurrentDirections
プロパティを変更できるようにし、それがで更新したいですUI。あなただけのクラス場所にSystem.ComponentModel.INotifyPropertyChangedインタフェースを実装する必要が
public class Location
{
public int ID { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public Quest[] AvailableQuests { get; set; }
public Monster[] LocationMonsters { get; set; }
public Location[] CurrentDirections { get; set; }
public Location(string name, string description, Quest[] availableQuests, int id)
{
Name = name;
Description = description;
AvailableQuests = availableQuests;
ID = id;
CurrentDirections = new Location[] { };
LocationMonsters = new Monster[] { };
AvailableQuests = new Quest[] { };
}
}
は、INotiftyPropertyChangedを調べて、私が望むものを達成しました。ありがとうございました。 –