PrintTaskOptionChangedEventArgs 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
当打印任务选项发生更改时调用。
public ref class PrintTaskOptionChangedEventArgs sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class PrintTaskOptionChangedEventArgs final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class PrintTaskOptionChangedEventArgs
Public NotInheritable Class PrintTaskOptionChangedEventArgs
- 继承
- 属性
Windows 要求
设备系列 |
Windows 10 (在 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox 中引入)
|
API contract |
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)
|
注解
下面是一个代码片段,演示如何在打印任务选项发生更改时检索对象。 首先,应用必须注册才能侦听选项更改。 更改选项后,将回调事件侦听器。
// Retrieve the advanced Print Task Options.
PrintTaskOptionDetails printDetailedOptions = PrintTaskOptionDetails.GetFromPrintTaskOptions(printTask.Options);
// Create a new list option.
PrintCustomItemListOptionDetails margins = printDetailedOptions.CreateItemListOption("Margins", "Margins");
margins.AddItem("WideMargins", "Wide", "Each margin is 20% of the paper size", await wideMarginsIconTask);
margins.AddItem("ModerateMargins", "Moderate", "Each margin is 10% of the paper size", await moderateMarginsIconTask);
margins.AddItem("NarrowMargins", "Narrow", "Each margin is 5% of the paper size", await narrowMarginsIconTask);
// Add the custom option to the option list
printDetailedOptions.DisplayedOptions.Add("Margins");
printDetailedOptions.OptionChanged += printDetailedOptions_OptionChanged;
async void printDetailedOptions_OptionChanged(PrintTaskOptionDetails sender, PrintTaskOptionChangedEventArgs args)
{
string optionId = args.OptionId as string;
if (string.IsNullOrEmpty(optionId))
{
return;
}
if (optionId == "Margins")
{
PrintCustomItemListOptionDetails marginsOption = (PrintCustomItemListOptionDetails)sender.Options["Margins"];
string marginsValue = marginsOption.Value.ToString();
switch (marginsValue)
{
case "WideMargins":
ApplicationContentMarginTop = 0.2;
ApplicationContentMarginLeft = 0.2;
break;
case "ModerateMargins":
ApplicationContentMarginTop = 0.1;
ApplicationContentMarginLeft = 0.1;
break;
case "NarrowMargins":
ApplicationContentMarginTop = 0.05;
ApplicationContentMarginLeft = 0.05;
break;
}
}
}
若要查看此的完整列表以及使用 PrintTask 的其他打印方案,请参阅 打印 和 UWP 打印示例。
属性
OptionId |
获取已更改的打印任务选项的 ID。 |