Thanks for checking in on me!
Made quite some progress in the meantime, however, I just hit another speed bump and have been spending most of my day on it.
As visible in the screenshot, I manage to draw on the canvas with my mouse but either only through single clicks (tedious) or with a MouseEnter event (drawing always on..)
Neither are what I wished for and I tried to work with a MouseDown event, which doesn't work. After some research I figured PreviewMouseDown should do the trick where MouseDown doesn't, but this doesn't work as well.
How can I make 'click dragging' work to paint with tiles?
This is my xaml part:
<DataTemplate>
<Image Source="{Binding MapTileImage}" Stretch="Fill" Width="{Binding Width}" Height="{Binding Height}">
<Image.InputBindings>
<MouseBinding MouseAction="LeftClick" Command="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=DataContext.ChangeTilesCommand}" CommandParameter="{Binding .}"/>
</Image.InputBindings>
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseEnter">
<command:EventToCommand Command="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=DataContext.ChangeTilesCommand}" CommandParameter="{Binding .}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Image>
</DataTemplate>
And in MainViewModel
private RelayCommand<BitmapModel> _changeTileCommand;
public RelayCommand<BitmapModel> ChangeTilesCommand {
get { return _changeTileCommand ?? (_changeTileCommand = new RelayCommand<BitmapModel>(UpdateTile)); }
}
with
void UpdateTile(BitmapModel tile) {
if (tile == null) return;
if (SelectedMapTile == null) return;
tile.MapTileImage = SelectedMapTile.MapTileImage;
}
Of course, the MouseAction is redundant with the introduction of Event "MouseEnter", but MouseEnter works regardless of the button state, which is my problem. No other event seems to work from MSDN. What can I do?