I cant get the buttons to bind to the Btn_AddNewDataModel_Click relay command can anybody help and also i need to send the CommandParameter model back any suggestions
Thanks
Madaxe
<Grid>
<Expander Header="Software" IsExpanded="True">
<Grid Margin="40,10,0,0">
<ItemsControl ItemsSource="{Binding Path=Media_Model.Vendors}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Expander Header="{Binding Name}" Margin="0,0,0,20">
<Grid Margin="20,10,0,0">
<ItemsControl ItemsSource="{Binding Software}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Content="{Binding Name}"
Width="100"
HorizontalAlignment="Left"
Margin="5,5,5,5"
Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}, Path=Btn_AddNewDataModel_Click}"
CommandParameter="{Binding}"
/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</Expander>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</Expander>
</Grid>
public class SoftwareInstallViewModel
{
private string _ConfigurationXMLPath = @"M:\Nikola\SoftwareList.json";
public Media_Model Media_Model { get; set; } = null;
public RelayCommand Btn_AddNewDataModel_Click { get; private set; }
public SoftwareInstallViewModel()
{
LoadConfigurationXML();
Btn_AddNewDataModel_Click = new RelayCommand(AddNewDataModel, CanAddNewDataModel);
}
public void AddNewDataModel(object message)
{
}
public bool CanAddNewDataModel(object message)
{
return true;
}
private void LoadConfigurationXML()
{
using (StreamReader streamReader = new StreamReader(_ConfigurationXMLPath))
{
string json = streamReader.ReadToEnd();
Media_Model = JsonConvert.DeserializeObject<Media_Model>(json);
}
}
}