i have a layout problem with XF page on winphone 8.
i want to create full native wp8 page and inject it all the content
of the XF page content (via Custom Renderer for example)
I tried few steps , and didn't succeed.
anyone can help?
Hey, could you please share a small description on the steps you followed but didn't success?
Thanks in advance!
yes . of course.
on XForms Samples , on Forms2Native
The example shows this code:
public class MyThirdPageRenderer : PageRenderer
protected override void OnElementChanged(ElementChangedEventArgs e)
var p = new MyThirdNativePage();
(MyThirdNativePage is a pure winphone page class)
the problem with that is that the winphone page is override every content
in the XForm Page.
what if i want to take the content on the Xform and inject it to the pure winphone page?
i tried to work with copy children, with the extension method: page.ConvertPageToUIElement
and didn't succeed.
how to do that?
or let my ask it differently.
if i have a XF page full of content.
and all i want is to change one control of it (maybe only small layout change)
how to do it on winphone?
You make a renderer for that piece that you would like to change. Not a page renderer, but lets say you wanted to change a TextCell to have it look different. You make a custom class inheriting from TextCell, then include a TextCellRenderer in the WP project.
This will allow you to change the native control being shown for a TextCell.
This can be extended to other controls, or custom controls.
thanks @AdamMeaney .
but what if all i want is to change the layout of one control (like put it bottom instead of at top)
so the easy way i think was to create new page, copy all content, and inject the one i want at the place i want.
how to do this?
So to clarify what you are looking to do, you have a Forms page.
On this page, there are controls, and you want to move one of those controls, but only on a certain platform?
If that is the case, renderers are overkill for what you are doing.
You need to assign its location differently based upon platform.
StackLayout pageLayout = new StackLayout
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
Orientation = StackOrientation.Vertical
Label child1 = new Label
Text = "First Child"
Label child2 = new Label
Text = "Second Child"
// WinPhone difference
if (Device.OS == TargetPlatform.WinPhone)
else // If you want to have them be child1 on top and 2 on bottom for Android/iOS
Thanks very much @AdamMeaney for your kind effort!
I wish it was so simple.
let me explain further .
i have a XF page full of controls.
now i want to put a new control at the bottom of that page.
(Programmatically and not manually - i want to make a derived page that for every
page with content my CustomPage will inject this control to the Bottom.
Now, for some reason, XForm page is implemented with CANVAS as the parent container -
(as u can see in pic 1-xamarinInjectWinPhone.PNG - i snapped it via Xaml Spy - the implementation page is
MainPage.xaml and under it the CANVAS control)
and as i know, canvas is a bad control for relative positioning - it using absolute positioning.
and i want to switch it to grid or dockpanel so i can inject my control and put it on the bottom.
(see pic 2 with grid as the container:
so as you see on pic 1, i created an new winphone pure native page with grid as the parent container.
and i want to inject the whole content to that grid, and finally to inject my control to the bottom.
(you can see from pic 1 that my new page - Page1.xaml is using grid under it)
sure it there was a way to replace the canvas with grid it was awesome.
but my question is general.
how can you inject the whole contant of XForm Page to the new pure WinPhone page (and after that
i can do easily my manipulation)
Thanks very much for your time!
Well that does clarify a bit better what you are looking for.
Unfortunately, I do not believe that is possible at this time. Someone can correct me if I am wrong, but that is my current understanding.
You should probably consider adding the new WP control to each Forms Page, instead of the other way around. It is simpler to implement in most cases.
Best of luck either way.
there is a possibility ...stackoverflow.com/questions/25685014/how-to-use-xamarin-form-controls-and-native-controls-on-the-same-page
but it is kind of complex
so i will drop of it .
Xamarin Inc., as a wholly-owned Microsoft subsidiary acting as a separate legal entity, adheres to the Microsoft Privacy Statement: Privacy & cookies