This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ErrorHandler | |
{ | |
using Result = FooInterfaces::Result; | |
using IStatefulLog = FooInterfaces::IStatefulLog; | |
public: | |
static Result HandleException(IStatefulLog& log, const uchar* functionName, std::exception_ptr eptr) | |
{ | |
Result result = Result::SUCCESS; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- This approach requires your view model to have a default (parameter-less) constructor. --> | |
<UserControl.DataContext> | |
<my:MyViewModel/> | |
</UserControl.DataContext> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial MyUserControl() | |
{ | |
InitializeComponent(); | |
Model.Initialize(DI.Resolve<IMyService>()); | |
Loaded += () => { Model.OnLoaded(); }; | |
Unloaded += () => { Model.OnUnloaded(); }; | |
} | |
public class MyViewModel | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<MySubView Project="{Binding SelectedProject}" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.ComponentModel; | |
using System.Runtime.CompilerServices; | |
namespace Product.App.ViewModels | |
public abstract class BindableBase : INotifyPropertyChanged { | |
public event PropertyChangedEventHandler PropertyChanged; | |
protected bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null) | |
{ | |
if (Equals(storage, value)) { | |
return false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class AsyncCommandBase : IAsyncCommand | |
{ | |
public abstract bool CanExecute(object parameter); | |
public abstract Task ExecuteAsync(object parameter); | |
public async void Execute(object parameter) | |
{ | |
await ExecuteAsync(parameter); | |
} | |
public event EventHandler CanExecuteChanged | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class DomainObject : INotifyPropertyChanged, | |
INotifyDataErrorInfo | |
{ | |
private ErrorsContainer<ValidationResult> errorsContainer = | |
new ErrorsContainer<ValidationResult>( x => this.RaiseErrorsChanged( x ) ); | |
public event EventHandler<DataErrorsChangedEventArgs> ErrorsChanged; | |
public bool HasErrors | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyViewModel : BindableBase | |
{ | |
public ICollectionView Customers { get; private set; } | |
public MyViewModel( ObservableCollection<Customer> customers ) | |
{ | |
// Initialize the CollectionView for the underlying model | |
// and track the current selection. | |
Customers = new ListCollectionView( customers ); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IDialogService { | |
MessageBoxResult ShowMessageBox(string messageBoxText, string caption = null, MessageBoxButton buttons = MessageBoxButton.OK,...); | |
} | |
public abstract class ViewModelBase : BindableBase { | |
public IDialogService DialogService => AppContext.Current.DialogService; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpGet] | |
//public async Task<FileStreamResult> GetTest() | |
public async Task<IActionResult> GetTest() | |
{ | |
using (var stream = new MemoryStream(Encoding.ASCII.GetBytes("Hello World"))) | |
{ | |
return new FileStreamResult(stream, new MediaTypeHeaderValue("text/plain")) | |
{ | |
FileDownloadName = "test.txt" | |
}; |