I would like complex button, which has several text elements and which should change their state and color depending on button state.
Unfortunately, I see that Xamarin button has only predefined image and text parameters.
How to have multiple controls inside a button in Xamarin?
Visual state manager(Only XF 3.0+) have three states: normal, disabled, focused which is named "CommonStates", or you can create custom states.Maybe it could help:
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/visual-state-manager
I think you must read more in content view, where you can add labels into stacklayout or grid with your own api bindable property, then use it wherever you want in your code:
https://learn.microsoft.com/en-us/dotnet/api/xamarin.forms.contentview
Related
Desired look
I wish to make a toolbar for my app that will contain some simple buttons, each with a single monochromatic icon. Here is an example of some toolbar buttons similar to I'm trying to achieve, from Mail's compose window:
Notice these buttons have a consistent size, inner padding, padding, and shading. This is a pretty consistent style across macOS, present in Mail, Safari, Finder, etc. This leads me to suspect there's a standardized UI component for creating such buttons.
If I use a segmented control, each button looks correct, with each icon being correctly padded:
Now I would like to add individual buttons that match the style.
Attempt 1
My first attempt was to add a "Push Button" (NSButton) to the toolbar:
This resulted in a wide button that's a bit too short, and not lined up with the segmented control:
Attempt 2
My second attempt was to use a segmented control, with only 1 segment.
This resulted in a button that's the right shape, size, etc., but it was off center relative to its label.
Naturally, I can manually adjust the button to match the goal, but I feel like I'm missing something. What's the proper way to create these standard buttons?
This is actually quite easy to do and you were close already.
You can use NSButton for that. Note that it has different styles (defined in NSButton.BezelStyle) to choose from. The default one is the one to use inside windows and modals. But for toolbars, to match the style of segmented controls and search bars, you can choose the style .texturedRounded.
You can also set the style via Interface Builder. Note that you have to select the button itself, not the toolbar item around it.
To get the correct size, you seem to set the icon within the toolbar item, not the button itself.
Here is my result:
I am newbie to Xamarin.Forms and stuck with a situation where I want to Create up a popup box with my control details.
How can I open and create custom dialog box / popup using Xamarin.Forms?
Any example code will be appreciated?
Thanks in advance!
What I have used is a StackLayout(or any layout) within a grid (or even an absolute layout ) this main grid will have 2 children. The IsVisible property of the popup layout will be set to false and when it is needed then the IsVisible property will be set to true and it will appear, something like this:
Grid mainGrid = new Grid{};
mainGrid.Children.Add(mainLayout,0,0);
mainGrid.Children.Add(popUpLayout,0,0);
Content = mainGrid;
if what you want is different then a custom renderer will be the way. Here are some helpful links:
http://blog.ostebaronen.dk/2013/02/using-dialogs-in-mono-for-android.html
https://forums.xamarin.com/discussion/30456/xamarin-forms-control-into-a-native-custom-dialog-android
There are different kind of things to achieve this, but I will say play with the layouts because it will work for all 3 platforms.
The Frame will be useful also:
https://developer.xamarin.com/api/type/Xamarin.Forms.Frame/
How do I place objects (i.e. labels or buttons) in a tab view in an Xcode mac app, so that when I click on a different tab the associated objects appear.
For example, I want to be able to put some labels in a tab called "Data" and some buttons in a tab called "Choice". When I press "Data" I want the labels to appear, but the buttons to not, and the other way around as well.
Is there an easy way to do this? Do I need to make a different class for each tab?
Each of the NSTabView's tab consists of as NSView. Here either you can draw all the buttons, labels or any other controls. Even you can add your new view from same xib or load it from other xib.
In the following image you can see, I have used a tabview with two tabs and in the object view you can see two views having two different static text.
And the tab change/click event is fired automatically you dont need to worry about it, the view will be loaded on tab click/change.
Use the built in cocoa view NSTabView which you can find in interface builder:
Each tab has its own view where you can place your objects.
This question about WP8 project.
I have a LongListSelector with pictures and html formatted text below. Currently each pictire implemented as an Item of the list. The last Item with browser has its own template and shows WebBrowser instead of picture.
I am expected this item behave such as TextBox which I can scroll by interacting with LongListSelector.
But this WebBrowser has it's own scroll inside and intercepts any surrounding scrolling events. Thus whenever I scroll down the list to show WebBrowserControl to the whole screen, I can't go back to the pictures.
Please help me with this issue. What is the appropriate solution? I need a separate pictures since want to implement "Clicked" logic on top of it. And I want to have WebBrowser too (but prefer to behave it similar to RichTextBox (which I can't find in WP8))
USE ListBox.ItemTemplate along with DataTemplate and inside dataTemplate we could custom create xaml tag !
Is there any way or are there any elements in WP7 which could be expanded on tap? For example if I'm using a ItemViewModel I'd like to show only the content of LineOne and when that is tapped I want to show the content of LineTwo.
I don't necessarily need to do this with a ItemViewModel. For example the hidden content could also be buttons that appear instead of a line of text.
Any suggestions?
Have you looked into the ExpanderView from the Silverlight Toolkit? It allows you to have a tap-to-expand template and a standard template. There's a reasonable overview of it available at Windowsphonegeek