How to custom renderer for WPF from forms toolbaritems

TommyMcConnellTommyMcConnell USMember
edited January 2018 in Cross Platform with Xamarin

I am creating an application using xf. On the windows platform, we are using WPF. The secondary toolbar overlays the title and is horizontally displayed. I would like to make the secondary menu display vertically. (Image attached)

I have attempted to create a CustomNavigationPageRenderer.
At this point I am unable to determine how to access the ToolBarItems and have them display vertically.

[assembly: ExportRenderer(typeof(CustomNavigationPage), typeof(CustomNavigationPageRender))]
namespace SDPNativeClient.WPF
{
    public class CustomNavigationPageRender: NavigationPageRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<NavigationPage> e)
        {
            base.OnElementChanged(e);
            var x = e;
        }

        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName.Equals("Renderer")) {
                var x = this.Control;
            }

            //var page = this.Element as NavigationPage;

            //if (page != null && _toolbar != null)
            //{
            //  Typeface tf = Typeface.CreateFromAsset(Android.App.Application.Context.Assets, "MyFont.ttf");

            //  TextView title = (TextView)_toolbar.FindViewById(Resource.Id.toolbar_title);
            //  title.SetText(page.CurrentPage.Title, TextView.BufferType.Normal);
            //  title.SetTypeface(tf, TypefaceStyle.Normal);
            //}
        }
    }
}

thank you,

Tommy McConnell

Answers

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    On the wpf platform {...}

    Are you trying to incorporate WPF (Windows Presentation Framework) in Xamarin app?
    Or trying to make WPF app that runs on multiple platforms?

    Or do you mean UWP - Universal Windows Platform. IE:Windows 8.1 and higher.

    I'm not trying to rag on you or anything - but if you're using wrong terms in your searches that could explain why you aren't finding anything relevant.

  • The application is built using xamarin forms project. WPF is just one of the platforms we want it to run on. The application renders in uwp, android with the secondary toolbaritems rendering vertically. In WPF the toolbar renders horizontally and overlays the title.

    thank you,

  • ClintStLaurentClintStLaurent USUniversity ✭✭✭✭✭

    WPF is just one of the platforms we want it to run on.

    No. WPF is not a platform. WPF is a XAML-based develop system. It is the system that the XAML language was originally created for - just in Windows. WPF was the replacement for Windows.Forms. WPF is basically the pre-cursor to Xamarin XAML. In Xamarin-XAML you have a StackLayout. In WPF-XAML you have a StackPanel and so on.

    I would strongly urge you to learn a bit more about your environment before trying to code for it. Sorry for how that sounds but if you don't understand what these terms mean then how can any of the tutorials or instructions make sense to you? And subsequently nobody reading your questions have a clue about what you're talking about.

    https://www.google.com/search?q=what+is+wpf&ie=utf-8&oe=utf-8&client=firefox-b-1

  • You are correct, Windows is the platform not WPF. For windows, custom code is in the wpf client project. I will edit the original post as the question still stands. I will continue to expand my knowledge of Xamarin and the associated technologies that it touches.
    thank you,

  • numereknumerek Member

    @ClintStLaurent said:

    WPF is just one of the platforms we want it to run on.

    No. WPF is not a platform. WPF is a XAML-based develop system. It is the system that the XAML language was originally created for - just in Windows. WPF was the replacement for Windows.Forms. WPF is basically the pre-cursor to Xamarin XAML. In Xamarin-XAML you have a StackLayout. In WPF-XAML you have a StackPanel and so on.

    I would strongly urge you to learn a bit more about your environment before trying to code for it. Sorry for how that sounds but if you don't understand what these terms mean then how can any of the tutorials or instructions make sense to you? And subsequently nobody reading your questions have a clue about what you're talking about.

    Had to remove this url because I have to be around for a little while longer before I can post links

    According to Xamarin, WPF is a platform.
    There is a microsoft document page called
    WPF Platform Setup - Xamarin | Microsoft Docs
    This forum won't let me link to it because I have to be around for a little while longer before I can post links

    On that web page there is the following:

    Platform Specifics
    You can determine what platform your Xamarin.Forms application is running on from either code or XAML. This allows you to change program characteristics when it's running on WPF. In code, compare the value of Device.RuntimePlatform with the Device.WPF constant (which equals the string "WPF"). If there's a match, the application is running on WPF.

    So under the heading Platform Specifics it specifies that WPF is a platform.

    @ClintStLaurent
    I would strongly urge you to learn a bit more about your environment before trying to create a forum post telling someone else they are not using the correct terminology.

  • jallensnowjallensnow Member ✭✭

    Did anyone ever figure this one out? I've got a similar question.

Sign In or Register to comment.