Saturday, 15 September 2012

c# - Add control to custom base page -



c# - Add control to custom base page -

i'm trying create custom base of operations page wp app. i'm doing creating new cs class file inherits phoneapplicationpage this:

public class basepage: phoneapplicationpage { //handle mutual non-visual stuff here }

the problem add together command on every page uses basepage basepage has no layoutroot or visual element can attach command to. there way can add together same command pages utilize basepage don't have copy/paste every time?

edit: adding xaml based on triggerpin's answer. i've created new xaml file basepage.cs throwing errors in basepage.g.cs: "myapp.mainpage contains definition '_contentloaded'" (and similar message 'layoutroot' , 'initializecomponent')

<local:basepage xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:phone="clr-namespace:microsoft.phone.controls;assembly=microsoft.phone" xmlns:shell="clr-namespace:microsoft.phone.shell;assembly=microsoft.phone" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:myapp.template" x:class="myapp.mainpage" mc:ignorable="d">

notice default, types derived phoneapplicationpage partial

public partial class mainpage : phoneapplicationpage

the partial definition allows split class definition across multiple files. commonly type, definition split between .cs , .xaml file.

<phone:phoneapplicationpage x:class="myproject.mainpage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:phone="clr-namespace:microsoft.phone.controls;assembly=microsoft.phone"> <!-- custom layout here --> </phone:phoneapplicationpage>

if create implementation partial class , provide base of operations xaml code, able want achieve.

c# silverlight windows-phone-7 windows-phone-8 windows-phone

No comments:

Post a Comment