How can a custom Xamarin.Forms theme specify a page's background color? - xamarin.forms

I am trying to create a custom theme following https://developer.xamarin.com/guides/xamarin-forms/themes/custom/, but it is unclear how a page's background color can be set via the theme.
I've tried creating an implicit style targeting a ContentPage. I've also tried creating a style class for the ContentPage. Neither works. It doesn't work since the actual page being loaded isn't a ContentPage, but rather subclassed page. In https://bugzilla.xamarin.com/show_bug.cgi?id=27659 Jason Smith states "Implicit styles do not apply to subclasses."
I'd love to take a look at the Xamarin.Forms.Themes source to see how the Forms team does it, but it doesn't appear to be available on GitHub.

#JoshuaLatusia said:
Hi, I found this to be working for all my pages.
By using "ApplyToDerivedTypes" you will set a generic style for all your Content pages.
Example:
<Style TargetType="ContentPage" ApplyToDerivedTypes="True">
<Setter Property="BackgroundColor" Value="#eeecf6" />
</Style>
See https://forums.xamarin.com/discussion/comment/302323/#Comment_302323

Related

How to change a toolbar item (logo) for different theme

I have a question. I need to have few toolbar items related to different styles. I have created Theme Resources and with the help of settings plugin I am saving different themes. However I would also like to have different toolbar items dedicated for each theme. I have tried to add my image in Resource dictionary like this
<ResourceDictionary>
<Image x:Key="logo" Source="IconSettings.png"></Image>
</ResourceDictionary>
and then in Xaml use it like this
<ToolbarItem IconImageSource="{DynamicResource logo}"/>
But nothing is displayed. Do you maybe have any suggestions even different approach?
Also have tried to follow this solution https://forums.xamarin.com/discussion/152758/setting-icon-file-names-as-resources
As you can see in the link you provided, why don't you try something like this
<ResourceDictionary>
<x:String x:Key="logo">IconSettings.png</x:String>
</ResourceDictionary>
And use it in your XAML.
You were trying to add image at the place of string input, that's the reason it showed you nothing
Let me know if its working fine or not

How to give styles for Angular 2 primeng auto search textbox?

Hi I have implemented auto search option in Angular 2 using primeng. I have found reference in https://www.primefaces.org/primeng/#/autocomplete site. when I implement same code in my project I do not see suggestions filling in drop-down box list. I have added screenshot below.
Below is my code.
<p-autoComplete autofocus name="username" [(ngModel)]="username" [suggestions]="filteredUsernamesSingle"(completeMethod)="filterUsernameSingle($event)" field="userName" [size]="30"
placeholder="Enter UserName" [minLength]="3" required></p-autoComplete>
In reference website when user tries to search some test, everything comes in dro-down list. But when I implement I am not getting any drop-down list as I shown in above image. Can someone help me where can I add styles to make suggestions come in drop-down box list?
I had the same problem. I was passing a string[] array into [suggestions]. After examining their example it started working after I started passing an array of objects instead. Apparently the autocomplete component expects an object with a property specified in the field directive, otherwise it can't reach the value and format it properly. Try passing it an object with a userName property, since in the HTML you specified field="userName".
Check the documentation page primefaces getting started. You'll see instructions to add the primeng css and primeicons and a theme css file that you will use as the theme for your site, to the project's angular.js file. This will work like <link rel="stylesheet" href="styles.css" /> embedding of external css files to a web page.

Set custom flag or variable in ghost editor

Is there any sort of easy way or helper that would enable to functionality to set custom variable flags. For example I could set a color variable to "blue" in the editor and I could use handlebars to add the "blue" class an element in that post.
EDIT: I ended up having to use a different CMS. Ghost was made intentionally to be simple and my needs require more customization features.
This is something I have been trying to figure out, but (being new to ghost), I haven't found a clean way to do this. Unlike Wordpress, there is no field for this in the editor (I have checked the documentation, nothing similar), so you have to apply some custom solution. Here are two options:
If the styling you want to apply depends on a tag, e.g. if 'movie'-tagged posts need some special styling, you can just add CSS because the {{body_class}} helper adds all the tags to the <body> element as tag-classname, e.g. tag-movie.
If tags are not your option, you could use client side JavaScript, check some condition in the content and apply the styling. I use this to change color of an svg logo when it is placed on a hero image that happens to have the same color as the logo. This requires the hero image of the post to follow some url convention, like post-heroimg3663-blue.jpg. Then you can add some inline Javascript to the <head> to change the color of the logo. Not so good, but it should work.
UPDATE:
If the second option works for you, you could even consider creating a Handlebars custom helper and running any styling (via adding a class) on the server side.

Dynamically loading CSS elements in asp.net

I searched google and SO, but did not find a solution.
I have an asp.net web app that allows users to customize some GUI aspects (such as font color, add a custom logo etc). This information is stored in the user profile database.
I have a css file that populates font colors etc. The main page, loads the users profile from the database, and customizes the page accordingly.
Aside from having each label with its own "font-color=", how can I display the CSS elements, based on the user profile information returned from the database? Thx
You can include an extra CSS file that points to an ASPX page:
<link rel="stylesheet" type="text/css" href="/CustomStyles.aspx" />
Then in CustomStyles.aspx change the default content-type:
Response.Clear()
Response.ContentType = "text/css"
Then just start outputting your styles:
Response.Write("#awesome-button{color:" & ColorFromDatabase & ";}"
Make sure that this file is included after the other styles so that it takes precedence. You might want to also throw an !IMPORTANT in there, too.
Response.Write("#awesome-button{color:" & ColorFromDatabase & " !IMPORTANT;}"
It depends on how you have the information stored, but you can add styling to elements through code like this:
Button1.Style["font-weight"] = "bold";
Or you can just apply a CSS class to the control:
Button1.CssClass = "buttonStyle";
You could have a page that just returns a CSS file based on the preferences stored in the database. So you would have:
<link rel="stylesheet" href="somepage.aspx?userid=<%=userID%>">
You could probably even do that easily enough with a classic ASP page, a web service, etc.
The point is that that page would generate the same basic stylesheet, filling in the right colors etc. that the user has chosen. This way you don't have to perform a bunch of style changes in server-side or client-side code after the page has loaded, or mix your user preference code in with your HTML, or change much about the base pages if you want to change the way the stylesheet works. It also makes it easy to test your stylesheet outside of testing the site itself.

How do I apply styling to my custom intro page?

I made my own welcome intro page using org.eclipse.ui.intro and I'm able to show my welcome extended with other contributors.
Now I'd like to decore my welcome with some css, and I have two question:
1) How can I apply predefined eclipse css (i.e Slate) to my page? I've already tried putting org.eclipse.ui.intro/INTRO_THEME = org.eclipse.ui.intro.universal.slate in plugin_customizazion.ini without success
2) there's a way to extend css to contributors without giving them the css file??? I mean there a way for contributors to use my own css if it is only inside my plugin (or eclipse plugin if i will be able to use "slate" style?)
Eclipse SDK Help
The only way to select a theme is via the preference org.eclipse.ui.intro/INTRO_THEME in plugin_customization.ini.
Theme-enabled intro implementation must make all the references to style and presentation resources using the $theme$ substitution variable. Absolute paths for images, pages, styles, etc. will be computed by resolving the substitution variable using the path of the currently active theme.
See Intro Content XML Format as well.
To answer the second question, if you define an intro theme which include your css file, other plugins will be able to use it for sure.
Cheers,
Max
Ok, now I've learned more about themes, but I think I have some problem with path.
I've defined my own theme, css and graphics, so I extend theme by configExtension. But when I load my application the welcome page doesn't load css neither images. I've also defined org.eclipse.ui.intro/INTRO_THEME in plugin_customization.ini.
I have a structure similar to slate template like this
my.plugin.name
|_resources
|_intro
|_graphics
|_html
in graphics there are all images definitions whlile in html there are css
then in intro I have my root.xhtml (referenced by intro.xml)
with this css reference
<link rel="stylesheet" href="$themes$/html/root-ie.css" type="text/css" charset="utf-8" />
finally I've defined configExtension with theme
<extension
point="org.eclipse.ui.intro.configExtension">
<theme
default="true"
id="my.plugin.name.themes.themename"
name="%theme.name.themenam"
path="/resources/intro"
scalable="true">
I think maybe the problem is with the path, I've also tried with path="resources/intro"
path="/resources/intro/" and path="resources/intro/" withous success
could someone post a simple but complete working sample please?

Resources