I am trying to use an eventToCommand to determine when the user mouses up on a slider control. However it is never getting fired. This is contained within a data template
<DataTemplate x:Key="RunEventsTemplate">
<di:DIGroupBox Grid.Row="2" Header="Real-Time Modifications" DataContext="{Binding DataContext.ScenarioHelper.EventPlayingService,RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Page}}}" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<di:DIGroupBox Header="Audio" DataContext="{Binding CurrentAudioEvent}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<di:DILabel Content="Filename: " />
<di:DIComboBox Grid.Column="1" />
<di:DICheckBox Grid.Row="1">Loop Audio File?</di:DICheckBox>
<di:DIImageToggleButton Grid.Row="1" Grid.Column="1" Height="23" Width="23" HorizontalAlignment="Left" Image="PlayIcon_White"></di:DIImageToggleButton>
</Grid>
</di:DIGroupBox>
<di:DIGroupBox Grid.Row="1" Header="Odors">
<ItemsControl ItemsSource="{Binding VehicleOdors}" ItemTemplate="{StaticResource ScentTemplate}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel></WrapPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</di:DIGroupBox>
<di:DIGroupBox Grid.Row="2" Header="Lighting" DataContext="{Binding CurrentLightingEvent}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width=".3*" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<di:DILabel Content="Color: " />
<di:DILabel Grid.Row="1" Content="Strobe: " />
<StackPanel Grid.Column="1" Orientation="Horizontal">
<di:DIRadioButton DIRadioButtonStyle="ToggleButton" IsChecked="{Binding CurrentDMXLightColor,Converter={StaticResource enumConverter},ConverterParameter={x:Null}}" Content="Off" Margin="0,0,5,0" Height="23" Width="50"></di:DIRadioButton>
<di:DIRadioButton DIRadioButtonStyle="ToggleButton" IsChecked="{Binding CurrentDMXLightColor,Converter={StaticResource enumConverter},ConverterParameter=White}" Content="White" Margin="0,0,5,0" Height="23" Width="50" />
<di:DIRadioButton DIRadioButtonStyle="ToggleButton" IsChecked="{Binding CurrentDMXLightColor,Converter={StaticResource enumConverter},ConverterParameter=Red}" Content="Red" Margin="0,0,5,0" Height="23" Width="50"/>
<di:DIRadioButton DIRadioButtonStyle="ToggleButton" IsChecked="{Binding CurrentDMXLightColor,Converter={StaticResource enumConverter},ConverterParameter=Blue}" Content="Blue" Height="23" Width="50"/>
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="Always On" Foreground="White" VerticalAlignment="Center" TextWrapping="Wrap" MaxWidth="50" Margin="0,0,5,0" />
<di:DISlider Minimum="0" Maximum="100" Value="{Binding StrobeRate}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseUp">
<cmd:EventToCommand Command="{Binding UserChangedSliderValueCommand}"></cmd:EventToCommand>
</i:EventTrigger>
</i:Interaction.Triggers>
</di:DISlider>
<TextBlock Text="Fast Strobe" Foreground="White" VerticalAlignment="Center" TextWrapping="Wrap" MaxWidth="50" />
</StackPanel>
</Grid>
</di:DIGroupBox>
<di:DIGroupBox Header="Smoke" Grid.Row="3" DataContext="{Binding CurrentSmokeEvent}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<di:DIToggleButton Content="Off" Width="50" Height="23">
</di:DIToggleButton>
<di:DILabel Grid.Column="1" Content="Intensity:" Margin="10,0,0,0" />
<di:DISlider Grid.Column="2" VerticalAlignment="Center" Value="{Binding Intensity}" Minimum="0" Maximum="100" >
</di:DISlider>
</Grid>
</di:DIGroupBox>
</Grid>
</di:DIGroupBox>
</DataTemplate>
The command looks like this
private RelayCommand userChangedSliderValueCommand;
public RelayCommand UserChangedSliderValueCommand
{
get
{
return userChangedSliderValueCommand = (userChangedSliderValueCommand??new RelayCommand(() =>
{
LightingEvent newLe = new LightingEvent();
newLe.DMXLightColor = CurrentDMXLightColor;
newLe.StrobeRate = StrobeRate;
UserAddNewEvent(newLe);
}
));
}
}
I set a break point and it never gets hit. I am using .net 4.5