html使用Android构造函数,MVVM:如何将参数传递给ViewModel的构造函数

using System;

using System.Xml.Linq;

using GalaSoft.MvvmLight.Messaging;

namespace Songhay.Wpf.WordWalkingStick.ViewModels

{

using Songhay.Office2010.Word;

using Songhay.OpenXml;

using Songhay.OpenXml.Models;

using Songhay.Wpf.Mvvm;

using Songhay.Wpf.Mvvm.ViewModels;

///

/// View Model for the default Client

///

public class ClientViewModel : ViewModelBase

{

///

/// Initializes a new instance of the class.

///

public ClientViewModel()

{

if(base.IsInDesignMode)

{

#region

this._flatOpcSourceString = ApplicationUtility

.LoadResource(

new Uri("/Songhay.Wpf.WordWalkingStick;component/PackedFiles/FlatOpcToHtml.xml",

UriKind.Relative));

this._xhtmlSourceString = ApplicationUtility

.LoadResource(

new Uri("/Songhay.Wpf.WordWalkingStick;component/PackedFiles/FlatOpcToHtml.html",

UriKind.Relative));

#endregion

}

else

{

this._flatOpcSourceString = "Loading…";

this._xhtmlSourceString = "Loading…";

//Receive MvvmLight message:

Messenger.Default.Register(this,

new Action>(

message =>

{

var tempDocFolder =

Environment.ExpandEnvironmentVariables("%UserProfile%/Desktop/");

var inputPath = tempDocFolder + "temp.docx";

var outputPath = tempDocFolder + "temp.html";

var flatOpcDoc =

XDocument.Parse(message.Content.TransformationResult);

OpenXmlUtility.TransformFlatToOpc(flatOpcDoc, inputPath);

this.FlatOpcSourceString = flatOpcDoc.Root.ToString();

var settings = new SonghayHtmlConverterSettings()

{

PageTitle = "My Page Title " + DateTime.Now.ToString("U"),

UseEntityMap = false

};

OpenXmlUtility.WriteHtmlFile(inputPath, outputPath, settings);

var xhtmlDoc = XDocument.Load(outputPath);

this.XhtmlSourceString = xhtmlDoc.Root.ToString();

}));

}

}

///

/// Gets or sets the flat opc source string.

///

/// The flat opc source string.

public string FlatOpcSourceString

{

get

{

return _flatOpcSourceString;

}

set

{

_flatOpcSourceString = value;

base.RaisePropertyChanged("FlatOpcSourceString");

}

}

///

/// Gets or sets the XHTML source string.

///

/// The XHTML source string.

public string XhtmlSourceString

{

get

{

return _xhtmlSourceString;

}

set

{

_xhtmlSourceString = value;

base.RaisePropertyChanged("XhtmlSourceString");

}

}

string _flatOpcSourceString;

string _xhtmlSourceString;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值