Universal Windows Apps: programmatically change font sizes application wide - xaml

In a UWP app I'd like to implement the capability of allowing the user to increasing/decreasing various font sizes (titles, subtitles, normal text, etc.) and was looking for a smart way of achieving this.
Bindings in style setters don't work in UWP and if possibile I'd like to leverage themes for font resizing.
Any suggestions or ideas?

I think you may make a Xaml with some style about the font and make user to select the style from xaml.In UWP change the style is easy.
And I think you may used the StaticResource ,try use the DynamicResource and when used increasing font you can change the resource.

Related

Trying to design App in portrait mode for desktop(13.3") but option is not available in uwp

I'm trying to design app in portrait mode in UWP but option is not available .
Any idea to achieve that.
Okay this target what you're trying to achieve is not advisable as Universal Windows Platform is for all device families and it's not advisable to make the UI of the application specific to only a single device type. Although there are no particular ways to achieve this, there are many workarounds,
Create a DesignHeight and DesignWidth for your application so that the Designer of visual studio knows what specific screen pixel size you're designing for.
Use MaxWidth and MaxHeight in your application to ensure the application doesn't use full screen sizes, use height/width properties of your page to not make the app size resizable (highly not recommended).
If Portrait view is what you must have then you can set the max width of your RootGrid and if the app screen size increases your maxWidth centre align your content. (this can be done by setting the MaxWidth = 900 property and the horrizontalAlignment property to stretch) (See the Zomato App on windows 10 desktop for a good idea)
To Set the designHeight/Width:
d:DesignHeight="500"
d:DesignWidth="400"
use the above in your page tag
For The point 2:
use Height="900" Width="450" in your Page Tag
For the Point 3:
<Grid HorizontalAlignment="Stretch" MaxWidth="900">
</Grid>

how to set form border thickness

I am writing an app using VB.net in VB2013. The Sizeable border is too thick in when displayed on PC's with later versions of Windows7, Windows 8(.1).
Does anyone know how to change the thickness of the window?
You don't get to control that. That's part of the user theme, and users can set any theme they want. You'll find it's also a problem on older versions of Windows if users have a theme with a wider border. You'll need to adjust your program's layout to allow for a little less space.
The border is drawn by the operating system, but you can create your own custom form, there is a library on CodePlex may help you to do what you need easily.
Drawing Custom Borders in Windows Forms

Custom button in Windows 8.1 app

I have a requirement to create a button in a Windows 8.1 app which has an icon and a text label. The icon will be a symbol from Segoe UI Symbols and the text label will be Segoe UI Semibold at a smaller text size.
I want to be able to reuse the button in different places within the app, using different icons and text labels.
How show I go about this? I could create a button and then edit the ContentPresenter to have a horizontally oriented stack panel with two TextBlocks, but then how could I reuse this? And how could I change the text in the two different text blocks?
Should I create a separate custom control with separate dependency properties for each of the textblock strings? I'm interested in hearing what you would do.
thanks
Create a simple Style. To make it easy, I would base it off the standardized AppBarButton style. You can format it to whatever size you want (I have done something similar to make a larger button or one with text on the side).
Have the main icon simply be a ContentPresenter which binds to the Content using a TemplateBinding. Make sure to set the FontFamily to Segoe UI Symbol. Have the text label pull from AutomationProperties.Name, similar to how the AppBarButton style does.
Then, whenever you want to use this just do:
<Button Style="{StaticResource MyCustomButtonStyle}"
Content="" // Where "000" is replaced by the number of the icon you wish to use.
AutomationProperties.Name="Text Label"/>
This should be extensible and easily reproducible to whatever location you need. When copying over the AppBarButton style, I suggest removing the artificial size limits (specifically the width of the main content Grid). I do suggest either giving the Text Label a fixed size or having it pull its size from the specified parent Width, so that it will Wrap correctly.
Hope this helps and happy coding!
Are you desiring to create something like for an AppBar? Take a look at AppBarButton and the style/types it supports. In Windows 8.1 we added some things around SymbolIcon specifically. Since you basically want two pieces of 'content' for your style you'll have to re-purpose one property (unless you create a custom control which doesn't sound needed for this scenario). Using AutiomationProperties.Name for the visible label is a good idea because it will also help with accessibility by default for those users.
Investigate the style for AppBarButton to get you started.

how to set default font and font style in cocoa app?

My app has all different kind of NSViews, including NSTabView, NSButton, NSTextField, NSPopupButton and so on.
I would like to change all display text to a certain font and with certain font style.
is there anyway to set the default font and font style in cocoa app?
I have tried:
How to loop through subviews in order to get the text of NSTextViews
however it doesn't work with NSTabView and NSButton.
I think that there must be an easy to do so, it's just I don't know what it is.
Please advise.
There isn't a built in way to do this (ie. by setting a key in Info.plist). You really do need to go through all the controls in your app, one way or another, and set a custom font for them. There are a few possible approaches. One is to use a custom subclass for all the controls for which you need to use a custom font. The subclass can be really minimal, it just needs to set the correct font upon initialization, possibly preserving other font attributes (size, color, etc.) setup in Interface Builder. Another option is to do as you've suggested and go through each subview in your app, check to see if it responds to -setFont:, and set your custom font if it does. I've used the first approach (subclass) with good success.

What's the best way to get around the lack of transparency in WixUI background images?

I'm using the Feature Tree UI, with a couple of custom dialogs. One of these has checkboxes on it. These checkboxes cannot be made to have transparent backgrounds, meaning I've had to colour in my background image the default background colour so that there aren't visible boxes around the checkboxes.
However, different versions of Windows have different default colouring! If I match the colour on Windows 7, it looks bad on XP, etc. Since the background images are Bitmaps, I can't make them transparent. What can I do to get around this problem?
From the WiX tutorial UI revisited chapter:
And a common complaint: no, the checkbox can't have a transparent
background. If you have a bitmap in the background, it will be ugly,
just like in our example above. The only workaround is to reduce the
width of the checkbox to the actual box itself and to place an
additional static text (these can be made transparent) adjacent to it.
This workaround has a side effect, although: in order to turn the checkbox on and off, you should click exactly in the box area, not the text. Comparing to the rest of Windows Installer UI limitations, it's slightly annoying :-)
Windows installer supports 32-bit bitmaps (ARGB), which means that the bitmap can be made transparent to show the default windows background color. This means, once your (not transparent) check-box is placed on top, you won't see the ugly box around the text, because it's the same color.
Note that windows photo viewer and the thumbnail preview in explorer DONT support transparencies, so you'll have to build and run your installer to see it working =D.
I used gimp to export to BMP with a transparency and it worked just fine with WIX.