jQuery – How to get all styles/css (defined within internal/external document) with HTML of an element

outerHTML (not sure, you need it — just in case) Limitations: CSSOM is used and stylesheets should be from the same origin. function getElementChildrenAndStyles(selector) { var html = $(selector).outerHTML(); selector = selector.split(“,”).map(function(subselector){ return subselector + “,” + subselector + ” *”; }).join(“,”); elts = $(selector); var rulesUsed = []; // main part: walking through all … Read more

How do I dynamically bind and statically add MenuItems?

You can use a CompositeCollection to do this, you can combine different Collections and add static items in the xaml. Example: Xaml: <Window x:Class=”WpfApplication8.MainWindow” xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Title=”MainWindow” Height=”233″ Width=”143″ Name=”UI”> <Window.Resources> <CollectionViewSource Source=”{Binding ElementName=UI, Path=Windows}” x:Key=”YourMenuItems”/> </Window.Resources> <Grid DataContext=”{Binding ElementName=UI}”> <Menu Height=”24″ VerticalAlignment=”Top”> <MenuItem Header=”_View” > <MenuItem Header=”Windows”> <MenuItem.ItemsSource> <CompositeCollection> <CollectionContainer Collection=”{Binding Source={StaticResource YourMenuItems}}” /> … Read more

WrapPanel as ItemPanel for ItemsControl

You might want to take a look at the ItemsPanel property: Gets or sets the template that defines the panel that controls the layout of items. Example: <ItemsControl> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <WrapPanel /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> </ItemsControl> And you can set it in a Style as follows: <Style TargetType=”ItemsControl”> <Setter Property=”ItemsPanel”> <Setter.Value> <ItemsPanelTemplate> <WrapPanel /> </ItemsPanelTemplate> </Setter.Value> … Read more

Python – how does passing values work?

Python uses a system sometimes called call-by-object. Nothing is copied when you pass arguments to a function. The names of the function arguments are locally bound within the function body, to the same objects provided in the function call. This is different from what most people think of as “call by value”, because it doesn’t … Read more

How do I group items in a WPF ListView

I notice one thing right away – the GroupStyle.HeaderTemplate will be applied to a CollectionViewGroup, so your DataTemplate should probably look like this: <GroupStyle> <GroupStyle.HeaderTemplate> <DataTemplate> <TextBlock FontSize=”15″ FontWeight=”Bold” Text=”{Binding Name}”/> </DataTemplate> </GroupStyle.HeaderTemplate> </GroupStyle> CollectionViewGroup.Name will be assigned the value of Status for that group.

How to change alert dialog header divider color android

You can actually change color of AlertDialog title by a very simple hack: public static void brandAlertDialog(AlertDialog dialog) { try { Resources resources = dialog.getContext().getResources(); int color = resources.getColor(…); // your color here int alertTitleId = resources.getIdentifier(“alertTitle”, “id”, “android”); TextView alertTitle = (TextView) dialog.getWindow().getDecorView().findViewById(alertTitleId); alertTitle.setTextColor(color); // change title text color int titleDividerId = resources.getIdentifier(“titleDivider”, “id”, … Read more

WPF – TabItem Background color changes when tabitem selected or hover over

Here is example of TabItem ControlTemplate Copy it to your resources and set wherever you need Red color as Background. SAMPLE <Window x:Class=”TestCustomTab.Window1″ xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Title=”Window1″ Height=”300″ Width=”300″> <Window.Resources> <SolidColorBrush x:Key=”RedBrush” Color=”Red”/> <SolidColorBrush x:Key=”SolidBorderBrush” Color=”#888″ /> <SolidColorBrush x:Key=”GreenBrush” Color=”Green” /> <SolidColorBrush x:Key=”DisabledBackgroundBrush” Color=”#EEE” /> <SolidColorBrush x:Key=”DisabledBorderBrush” Color=”#AAA” /> <SolidColorBrush x:Key=”DisabledForegroundBrush” Color=”#888″ /> <Style TargetType=”{x:Type TabItem}”> … Read more

Styling a SearchView in Android Action Bar

I have been spending many time for this but finally: 🙂 To change the text color : ((EditText)searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text)).setTextColor(Color.WHITE); or this one for AndroidX: ((EditText)searchView.findViewById(androidx.appcompat.R.id.search_src_text)).setTextColor(Color.WHITE); To change the text hint: ((EditText)searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text)).setHintTextColor(Color.WHITE); or this one for AndroidX: ((EditText)searchView.findViewById(androidx.appcompat.R.id.search_src_text)).setHintTextColor(Color.WHITE);

Setting Button FlatStyle in WPF

The ToolBar class defines a Style that makes Buttons look flat. An example of using it is: <Button Style=”{StaticResource {x:Static ToolBar.ButtonStyleKey}}”/> This also works for a ToggleButton when using ToggleButtonStyleKey. WPF lets you completely restyle controls to make them look like whatever you want, which is why it doesn’t have such a specific FlatStyle property … Read more