Hej, mam problem z commandem od buttona.
Kod:
Viewer:
<TextBox Name="ValueEditor"
Grid.Column="0"
Text="{Binding Path=Value, UpdateSourceTrigger=PropertyChanged}"
Background="{Binding Path=ValidationColor}"
Style="{StaticResource FieldTextBoxStyle}"
ToolTip="{Binding Path=FieldValueText}"/>
<StackPanel HorizontalAlignment="Left"
Width="100" Margin="0 20 0 0"
Visibility="{Binding ElementName=ValueEditor,Path=IsKeyboardFocusWithin,
Converter={StaticResource boolToVis}}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ItemsControl ItemsSource="{Binding IntelliHintVM.Hints}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Content="{Binding Content}" Command="{Binding HintCommand}" FontSize="11"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</StackPanel>
ViewModel:
private Color _background;
private string _textAboutTest;
private ObservableCollection<ButtonIntelliHint> _hints;
public Color Background
{
get { return _background; }
set
{
_background = value;
RaisePropertyChanged(() => Background);
}
}
public ObservableCollection<ButtonIntelliHint> Hints
{
get { return _hints; }
set { _hints = value; RaisePropertyChanged(() => Hints); }
}
public string TextAboutTest
{
get { return _textAboutTest; }
set { _textAboutTest = value; RaisePropertyChanged(() => TextAboutTest); }
}
public IntelliHintViewModel(List<string> hints)
{
CreateButtons(hints);
}
private void CreateButtons(List<string> hints)
{
if (Hints is null)
Hints = new ObservableCollection<ButtonIntelliHint>();
foreach (string val in hints)
Hints.Add(new ButtonIntelliHint(this, val));
}
public void ApplyHint(string textBoxValue)
{
}
oraz viewmodel od ButtonIntelliHint
IntelliHint.IntelliHintViewModel ViewModel { get; set; }
public string Content { get; set; }
public ICommand HintCommand { get; private set; }
public ButtonIntelliHint(IntelliHint.IntelliHintViewModel vm, string value)
{
ViewModel = vm;
Content = value;
HintCommand = new RelayCommand(ExecuteHint);
}
private void ExecuteHint()
{
ViewModel.ApplyHint(this.Content);
}
Nie wiem dlaczego nie chce mi wejść w ogóle w tego commanda. Content jest pobierany normalnie i wyświetla się wszystko jak powinno. Jakieś pomysły?