2
如果要創建WPF窗口或WPF頁面,可以將命令綁定到XAML中的函數。通過PageFunction窗體上的XAML設置命令綁定
<Page x:Class="WpfPageApplication.Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:WpfPageApplication="clr-namespace:WpfPageApplication"
Title="Page1" Background="LightGray"
>
<Page.CommandBindings>
<CommandBinding
Command="WpfPageApplication:PizzaCommands.ConfigurePizza"
Executed="OnConfigurePizza" />
</Page.CommandBindings>
還有另一種類型的WPF表格:a PageFunction
。但它不會讓你鍵入:
<PageFunction.CommandBindings>
我可以猜測兩種可能的解釋:
- 因爲
PageFunction
是一個通用的對象,你必須以某種方式進入泛型參數到XAML。 - 這只是框架中的不一致。
有誰知道我可以在XAML中的PageFunction
配置CommandBindings
? (我知道我可以在代碼中做到這一點,但這不是重點)。
我試過。有用。 –
2009-07-01 00:09:16