public RelayCommand(Action<object> execute, Func<object, bool> canExecute = null)
{
this.execute = execute;
this.canExecute = canExecute;
}
public bool CanExecute(object parameter)
{
return canExecute == null || canExecute(parameter);
}
public void Execute(object parameter)
{
execute(parameter);
}
<Button x:Name="button" Content="Folder 1" HorizontalAlignment="Left" Margin="10,87,0,0" VerticalAlignment="Top" Width="57" Command="{Binding BrowseFolder}" CommandParameter="0"/>
<Button x:Name="button_Copy" Content="Folder 2" HorizontalAlignment="Left" Margin="683,87,0,0" VerticalAlignment="Top" Height="19" Width="66" Command="{Binding BrowseFolder}" CommandParameter="1"/>
private string txtb1;
public string TextBox1 {
get { return txtb1; }
set
{
txtb1 = value;
OnPropertyChanged("IndicatedPath");
}
}
public ICommand BrowseFolder
{
get { return new RelayCommand((obj) =>
{
Winforms.FolderBrowserDialog fbd = new Winforms.FolderBrowserDialog();
fbd.RootFolder = Environment.SpecialFolder.DesktopDirectory;
fbd.Description = "Select Folder";
fbd.ShowNewFolderButton = false;
if (fbd.ShowDialog() == Winforms.DialogResult.OK)
{
TextBox1 = fbd.SelectedPath;
}
}); }
}
<TextBox x:Name="TextBox" HorizontalAlignment="Left" Margin="88,88,0,0" Text="{Binding TextBox1}" TextWrapping="Wrap" VerticalAlignment="Top" Width="120" Height="19" />
PostData postData;
if (isLiked)
{
var likesCount = conn.ExecuteReader("SELECT (Likes) FROM PostData AS pd WHERE pd.MessageId = @MessageId", new { messageId }).Parse<int>().FirstOrDefault();
conn.Close();
var temp = 1;
if (likesCount > 0)
{
temp = likesCount++;
}
try
{
conn.Open();
conn.Execute("UPDATE PostData SET Likes = @Likes WHERE MessageId = @MessageId", new { Likes = temp, messageId });
//using (SQLiteCommand cmd = new SQLiteCommand($"UPDATE PostData SET Likes = '{temp}' WHERE MessageId = '{messageId}'", conn))
//{
// cmd.ExecuteNonQuery();
//}
}
catch (Exception ex)
{
Console.WriteLine(ex);
throw;
}
IEnumberable<Car> numbers