English 中文(简体)
等量为7毫升?
原标题:Equivalent of includes in wp7 sl?

通过 当你重新设计对窗户电话的相对较大应用时,Uris是疼痛的一环,因此我写了一个简单的方法,如:

void Navigate(string Frame)
{
       NavigationService.Navigate(new Uri(string.Format("/{0}.xaml", 0), UriKind.Relative));
}

问题在于,我想把这一守则列入所有正在做一些航行的电话应用系统,但我很想知道,复印件和过去是否是唯一的选择,我通常会试图使我的网页来自一个有办法的类别,并从基类中解脱,但这将是另一个痛苦,因为<代码>。 电话应用 页: 1 是否有其他更好的办法实现这一目标,或者我是否只是复制和过去?

Thanks.

最佳回答

您可将这种方法推向静态类别,然后将打电话页作为参考。

public static class Navigator
{
    public static void Navigate(Page page, string frame)
    {
        page.NavigationService.Navigate(new Uri(string.Format("/{0}.xaml", frame), UriKind.Relative));
    }
}

那么,你就这样说:

Navigator.Navigate(this, "NewPage");
问题回答

我看不到任何问题。

创建您的电话:

public class PhoneApplicationPageBase : PhoneApplicationPage
    {
        public void Navigate()
        {

        }
        // Others methods
    }

页: 1

public partial class Page1 : PhoneApplicationPageBase
    {
        public Page1()
        {
            InitializeComponent();
        }
    }

and in xaml too:

<my:PhoneApplicationPageBase
    x:Class="Views.Page1"
    ...>

</my:PhoneApplicationPageBase>

或更多。 你可以创造推广方法。

 public static class Ext
    {
        public static void Navigate(this Page page, string view)
        {

        }
    }

然后使用this.Navigate (“Page2.xaml”

我同意罗马的看法,即从基页衍生出来的过程最糟糕的是: 几个扼杀性替代物,你做了调整。

I ve got my own little mvvm toolkit, which includes a navigator service that (basically) maps uri s to page classes. On application start up you map page classes to uri s, and afterwards you can simply navigate to a view (uri) by specifying the class.

i.e. 在估价人登记意见时:

    ViewNavigator.RegisterView<IMainView>(new Uri("/Pages/MainView.xaml", UriKind.RelativeOrAbsolute));

从代码上看,你可以通过使用手法打一页。

    ViewNavigator.Instance.NavigateTo<IMainView>();

整个工具包比此处描述的要先进(支持参数;包括允许你通过XAML这样做的行为),但我希望你会得到一般的想法。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签