本文整理汇总了C#中IViewModel类的典型用法代码示例。如果您正苦于以下问题:C# IViewModel类的具体用法?C# IViewModel怎么用?C# IViewModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IViewModel类属于命名空间,在下文中一共展示了IViewModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowWindow
public int ShowWindow(ViewModelType type, IViewModel viewModel)
{
KeyValuePair<int, Window> k = this.CreateWindow(type, viewModel);
viewModel.WindowId = k.Key;
k.Value.Show();
return k.Key;
}
示例2: AsyncMethodWithViewModel
private async void AsyncMethodWithViewModel(IAsyncOperation<bool> asyncOperation, bool result, IViewModel viewModel)
{
bool b = await asyncOperation;
b.ShouldEqual(result);
ViewModel = viewModel;
AsyncMethodInvoked = true;
}
示例3: Export
/// <summary>
/// Exports the <paramref name="viewModel" />'s view to the print or clipboard or file.
/// </summary>
/// <param name="viewModel">The view model.</param>
/// <param name="exportMode">The export mode.</param>
/// <param name="dpiX">The dpi X.</param>
/// <param name="dpiY">The dpi Y.</param>
/// <exception cref="System.InvalidOperationException"></exception>
/// <exception cref="System.ArgumentNullException">The <paramref name="viewModel" /> is <c>null</c>.</exception>
/// <remarks>If <paramref name="exportMode" /> is <see cref="ExportMode.Print" /> then the <paramref name="dpiX" /> and <paramref name="dpiY" /> argument will be ignored.</remarks>
public virtual void Export(IViewModel viewModel, ExportMode exportMode = ExportMode.Print, double dpiX = 96, double dpiY = 96)
{
Argument.IsNotNull(() => viewModel);
var view = _viewManager.GetViewsOfViewModel(viewModel).OfType<UIElement>().FirstOrDefault();
if (view == null)
{
string message = string.Format(CultureInfo.InvariantCulture, "There no an active view for this view model of type '{0}'", viewModel.GetType().FullName);
Log.Error(message);
throw new InvalidOperationException(message);
}
if (exportMode == ExportMode.Print)
{
Print(view);
}
else
{
var bitmap = CreateImageFromUIElement(view, dpiX, dpiY);
#if !SILVERLIGHT
if (exportMode == ExportMode.File)
{
SaveToFile(bitmap);
}
else
{
Clipboard.SetImage(bitmap);
}
#else
SaveToFile(bitmap);
#endif
}
}
示例4: CloseItem
public void CloseItem(IViewModel parentViewModel)
{
DeactivateItem(parentViewModel, true);
_activatedItems.Pop();
if (_activatedItems.Any())
base.ActivateItem(_activatedItems.Peek());
}
示例5: TraceViewModel
public static void TraceViewModel(AuditAction auditAction, IViewModel viewModel)
{
Action<AuditAction, IViewModel> handler = TraceViewModelHandler;
if (handler != null)
handler(auditAction, viewModel);
ServiceProvider.Tracer.TraceViewModel(auditAction, viewModel);
}
示例6: ReleaseViewModel
public void ReleaseViewModel(IViewModel viewModel)
{
if (viewModel != null)
{
ReleaseViewModelInstance(viewModel);
}
}
示例7: Export
/// <summary>
/// Exports the <paramref name="viewModel" />'s view to the print or clipboard or file.
/// </summary>
/// <param name="viewModel">The view model.</param>
/// <param name="exportMode">The export mode.</param>
/// <param name="dpiX">The dpi X.</param>
/// <param name="dpiY">The dpi Y.</param>
/// <exception cref="System.InvalidOperationException"></exception>
/// <exception cref="System.ArgumentNullException">The <paramref name="viewModel" /> is <c>null</c>.</exception>
/// <remarks>If <paramref name="exportMode" /> is <see cref="ExportMode.Print" /> then the <paramref name="dpiX" /> and <paramref name="dpiY" /> argument will be ignored.</remarks>
public virtual void Export(IViewModel viewModel, ExportMode exportMode = ExportMode.Print, double dpiX = 96, double dpiY = 96)
{
Argument.IsNotNull("viewModel", viewModel);
var view = _viewManager.GetViewsOfViewModel(viewModel).OfType<UIElement>().FirstOrDefault();
if (view == null)
{
throw Log.ErrorAndCreateException < InvalidOperationException >("There no an active view for this view model of type '{0}'", viewModel.GetType().FullName);
}
var bitmap = CreateImageFromUIElement(view, dpiX, dpiY);
if (exportMode == ExportMode.Print)
{
Print(bitmap);
}
else
{
#if !SILVERLIGHT
if (exportMode == ExportMode.File)
{
SaveToFile(bitmap);
}
else
{
Clipboard.SetImage(bitmap);
}
#else
SaveToFile(bitmap);
#endif
}
}
示例8: WindowLogic
/// <summary>
/// Initializes a new instance of the <see cref="WindowLogic"/> class.
/// </summary>
/// <param name="targetWindow">The window this provider should take care of.</param>
/// <param name="viewModelType">Type of the view model.</param>
/// <param name="viewModel">The view model to inject.</param>
/// <exception cref="ArgumentNullException">The <paramref name="targetWindow"/> is <c>null</c>.</exception>
public WindowLogic(IView targetWindow, Type viewModelType = null, IViewModel viewModel = null)
: base(targetWindow, viewModelType, viewModel)
{
var targetWindowType = targetWindow.GetType();
string eventName;
var closedEvent = targetWindowType.GetEventEx("Closed");
if (closedEvent != null)
{
eventName = "Closed";
_dynamicEventListener = new DynamicEventListener(targetWindow, "Closed", this, "OnTargetWindowClosed");
}
else
{
eventName = "Unloaded";
_dynamicEventListener = new DynamicEventListener(targetWindow, "Unloaded", this, "OnTargetWindowClosed");
}
_targetWindowClosedEventName = eventName;
Log.Debug("Using '{0}.{1}' event to determine window closing", targetWindowType.FullName, eventName);
}
示例9: OnPropertyChanging
public override void OnPropertyChanging(IViewModel viewModel, string propertyName, object oldValue)
{
OnPropertyChangingCalled = true;
OnPropertyChangingViewModel = viewModel;
OnPropertyChangingPropertyName = propertyName;
OnPropertyChangingOldValue = oldValue;
}
示例10: OnPropertyChanged
public override void OnPropertyChanged(IViewModel viewModel, string propertyName, object newValue)
{
OnPropertyChangedCalled = true;
OnPropertyChangedViewModel = viewModel;
OnPropertyChangedPropertyName = propertyName;
OnPropertyChangedNewValue = newValue;
}
示例11: SetContext
public static EventHandler SetContext(IViewModel viewModel)
{
return (o,e) =>
{
(o as FrameworkElement).DataContext = viewModel;
};
}
示例12: CreateWindow
private KeyValuePair<int, Window> CreateWindow(ViewModelType type, IViewModel viewModel)
{
this.index++;
Window window;
switch (type)
{
case ViewModelType.LoginWindow:
window = new LoginWindow {DataContext = viewModel};
break;
case ViewModelType.MainWindow:
window = new MainWindow {DataContext = viewModel};
break;
case ViewModelType.SettingsWindow:
window = new SettignsWindow { DataContext = viewModel };
break;
default:
window = new Window { DataContext = viewModel };
break;
}
window.DataContext = viewModel;
KeyValuePair<int, Window> keyValuePair = new KeyValuePair<int, Window>(this.index, window);
this.windows.Add(keyValuePair);
return keyValuePair;
}
示例13: Create
public BindingExpression Create(IViewModel viewModel, String elementId, String targetProperty, Binding binding)
{
var type = viewModel.GetType();
// find property dic
IDictionary<string, MemberInfo> propertyDic;
if(!_typeBindingDic.TryGetValue(type, out propertyDic))
{
propertyDic = new Dictionary<string, MemberInfo>();
_typeBindingDic[type] = propertyDic;
}
MemberInfo propertyInfo = null;
if(!propertyDic.TryGetValue(targetProperty, out propertyInfo))
{
// find the member...
propertyInfo = type.GetMember(targetProperty).FirstOrDefault();
if(propertyInfo == null)
{
return null;
}
propertyDic[targetProperty] = propertyInfo;
}
var bindingExpression = new BindingExpression(binding, propertyInfo, viewModel);
return bindingExpression;
}
示例14: CongregatePresenter
/// <summary>
/// Initializes a new instance of the <see cref="CongregatePresenter"/> class.
/// </summary>
/// <param name="view">The view.</param>
/// <param name="stockItemView">The stock item view.</param>
/// <param name="bankAccountView">The bank account view.</param>
/// <param name="model">The model.</param>
public CongregatePresenter(ICongregateView view, IStockItemView stockItemView, IBankAccountView bankAccountView, IViewModel model)
{
this._View = view;
this._StockItemView = stockItemView;
this._BankAccountView = bankAccountView;
this._Model = model as AppDataManager;
}
示例15: MainView
public MainView()
{
InitializeComponent();
vm = DataContext as IViewModel;
vm.OnActivate();
tabControl.SelectionChanged += Items_CurrentChanged;
}