RichEditBox 使用自定義選單

2022-01-16 06:01:32 字數 2578 閱讀 1568

老周:當richeditbox控制項的上下文選單即將彈出時,會引發contextmenuopening事件,我們需要處理該事件,並且將e.handled屬性設定為true,這樣才能阻止預設上下文選單的彈出

在richeditbox控制項上宣告附加的選單項

name="redit"

grid.row="3"

margin="10,10,10,10"

contextmenuopening="oncontextmenuopening">

text="複製"

click="oncopy"/>

text="剪下"

click="oncut"/>

text="貼上"

click="onpaste"/>

text="字型大小">

text="16"

tag="16"

click="onfontsize" />

text="20"

tag="20"

click="onfontsize"/>

text="24"

tag="24"

click="onfontsize" />

text="36"

tag="36"

click="onfontsize"/>

text="48"

tag="48"

click="onfontsize"/>

menuflyoutsubitem>

text="加粗"

click="onbold" />

text="下劃線">

text="無"

tag="-1"

click="onunderline" />

text="單實線"

tag="0"

click="onunderline"/>

text="雙實線"

tag="1"

click="onunderline"/>

text="虛線"

tag="2"

click="onunderline"/>

menuflyoutsubitem>

text="顏色">

text="黑色"

tag="黑色"

click="ontinct"/>

text="藍色"

tag="藍色"

click="ontinct"/>

text="白色"

tag="白色"

click="ontinct"/>

menuflyoutsubitem>

menuflyout>

flyoutbase.attachedflyout>

richeditbox>

處理oncontextmenuopening

private

void

oncontextmenuopening(object sender , contextmenueventargs e)

處理複製貼上

private

void

oncopy(object sender , routedeventargs e)

private

void

oncut(object sender , routedeventargs e)

private

void

onpaste(object sender , routedeventargs e)

處理onfontsize

///

/// 設定字型

//////

///private

void

onfontsize(object sender , routedeventargs e)

///

/// 加粗

//////

///private

void

onbold(object sender , routedeventargs e)

private

void

onunderline(object sender , routedeventargs e)

redit.document.selection.characterformat.underline = unlinetp;

}

private void ontinct(object sender , routedeventargs e)

redit.document

.selection

.characterformat

.backgroundcolor = color;

}

顏色在windows.ui.color

裡面**都是抄老周的

參考:

RichEditBox 使用自定義選單

老周 當richeditbox控制項的上下文選單即將彈出時,會引發contextmenuopening事件,我們需要處理該事件,並且將e.handled屬性設定為true,這樣才能阻止預設上下文選單的彈出 在richeditbox控制項上宣告附加的選單項 name redit grid.row 3 ...

使用 NSUserDefaults 儲存自定義物件

nsuserdefaults是乙個單例,在整個程式中只有乙個例項物件,他可以用於資料的永久儲存,而且簡單實用,可以讓資料自由傳遞。nsuserdefaults支援的資料型別有 nsnumber nsinteger float double nsstring,nsdate,nsarray,nsdict...

使用自定義資源

01 02 description write resource to file 03 author fzy112001 04 param hmodule,handle of exe dll 05 param lpname,name of the resource 06 param lptype,r...