How can I achieve a dashed or dotted border in WPF?

This worked great in our application, allowing us to use a real Border and not mess around with Rectangles: <Border BorderThickness=”1,0,1,1″> <Border.BorderBrush> <DrawingBrush Viewport=”0,0,8,8″ ViewportUnits=”Absolute” TileMode=”Tile”> <DrawingBrush.Drawing> <DrawingGroup> <GeometryDrawing Brush=”Black”> <GeometryDrawing.Geometry> <GeometryGroup> <RectangleGeometry Rect=”0,0,50,50″ /> <RectangleGeometry Rect=”50,50,50,50″ /> </GeometryGroup> </GeometryDrawing.Geometry> </GeometryDrawing> </DrawingGroup> </DrawingBrush.Drawing> </DrawingBrush> </Border.BorderBrush> <TextBlock Text=”Content Goes Here!” Margin=”5″/> </Border> Note that the Viewport … Read more

How do you disable MouseOver effects on a Button in WPF?

Look what your control template boils down to: <ControlTemplate TargetType=”{x:Type Button}”> <Button> <ContentPresenter/> </Button> </ControlTemplate> You’re saying, “I want to replace the look of my button with… a button.” The usage of the ControlTemplate is to replace the visual tree of a control. So you are replacing the visual tree of the existing button with … Read more

Apply two different font styles to a TextView

One way to do this is to extend TypefaceSpan: import android.graphics.Paint; import android.graphics.Typeface; import android.text.TextPaint; import android.text.style.TypefaceSpan; public class CustomTypefaceSpan extends TypefaceSpan { private final Typeface newType; public CustomTypefaceSpan(String family, Typeface type) { super(family); newType = type; } @Override public void updateDrawState(TextPaint ds) { applyCustomTypeFace(ds, newType); } @Override public void updateMeasureState(TextPaint paint) { applyCustomTypeFace(paint, newType); … Read more

Style SnackBar in theme app

With the Material Components Library you can globally change the snackbar style in your app theme: <style name=”AppTheme” parent=”Theme.MaterialComponents.*”> <!– Style to use for Snackbars in this theme. –> <item name=”snackbarStyle”>@style/Widget.MaterialComponents.Snackbar</item> <!– Style to use for action button within a Snackbar in this theme. –> <item name=”snackbarButtonStyle”>@style/Widget.MaterialComponents.Button.TextButton.Snackbar</item> <!– Style to use for message text within … Read more

Switching CSS classes based on screen size

CSS Media Queries are definetly the way to go. You can easily separate your CSS based upon the browser size, pixel density, etc. Here’s a list of examples from CSS-Tricks. /* Smartphones (portrait and landscape) ———– */ @media only screen and (min-device-width : 320px) and (max-device-width : 480px) { /* Styles */ } /* Smartphones … Read more

Remove Highlight Effect from ListViewItem

I don’t know if this is the only solution but I did it as follows (by setting the Template property of the ListViewItems): <ListView.ItemContainerStyle> <Style TargetType=”{x:Type ListViewItem}”> <Setter Property=”Background” Value=”Transparent” /> <Setter Property=”Template”> <Setter.Value> <ControlTemplate TargetType=”{x:Type ListViewItem}”> <Border BorderBrush=”Transparent” BorderThickness=”0″ Background=”{TemplateBinding Background}”> <GridViewRowPresenter HorizontalAlignment=”Stretch” VerticalAlignment=”{TemplateBinding VerticalContentAlignment}” Width=”Auto” Margin=”0″ Content=”{TemplateBinding Content}”/> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> … Read more

WPF window style not being applied

It appears that there is no proper solution to your problem. TargetType in Styles doesn’t manage derived types. Here are two alternatives : You can put a key in your style and apply the style to all your Windows. <!– Resource file –> <ResourceDictionary …> <Style TargetType=”{x:Type Window}” x:Key=”WindowDefaultStyle”> <!– …. –> </Style> </ResourceDictionary> <!– … Read more

CSS align images and text on same line

You can either use (on the h4 elements, as they are block by default) display: inline-block; Or you can float the elements to the left/rght float: left; Just don’t forget to clear the floats after clear: left; More visual example for the float left/right option as shared below by @VSB: <h4> <div style=”float:left;”>Left Text</div> <div … Read more