UWP ToggleSwitch put Content on the Left - xaml

Is there an easy way to get the content (text) on the left side of a ToggleSwitch control? (Else than messing up the Template).
Thanks

You should alter the template if you want to do it correctly.
However, if you want to fix it in a hacky way, change the FlowDirection of the control. But then you'll have to tweak with margins and alignments to make it look decent when used with other controls (see image below for default alignment).
<StackPanel>
<ToggleSwitch OffContent="Test" OnContent="Test2"></ToggleSwitch>
<ToggleSwitch OffContent="Test" OnContent="Test2" FlowDirection="RightToLeft"></ToggleSwitch>
</StackPanel>

A modified template displaying SwitchToggle content on the left can be found here.

Related

UWP mediaplayerelement how to display extra text on top part of transport media control?

I am writing a UWP 14393 app using mediaplayerelement in xaml file, I am wondering how can I display extra information in text on top of custom transport media control so that when player control is up, the text will show up at the same time?
For example, for a video player showing an online stream, and at the top left corner shows streamer name, view count, etc. The information only shows up when player control shows up.
Obviously, the best way to do this is to put the text inside custom transport media control, is it doable? If not, how can I achieve this?
I am a newbie at UWP, so any help will be welcome, thanks.
You can custom the MediaTransportControls's style, and add your own content to <Border x:Name="ControlPanel_ControlPanelVisibilityStates_Border">. See my test.
First download MediaTransportControls's style from my gist.
Or you can find it in your pc's generic.xaml file.
Then add this style to App.xaml.
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/MediaTransportControls.xaml"/>
</ResourceDictionary.MergedDictionaries>
Then you can use your style in MediaTransportControls.
<MediaPlayerElement
Width="300" Height="500"
AreTransportControlsEnabled="True"
Source="ms-appx:///Assets/elephantsdream-clip-h264_sd-aac_eng-aac_spa-aac_eng_commentary-srt_eng-srt_por-srt_swe.mkv">
<MediaPlayerElement.TransportControls>
<MediaTransportControls Style="{StaticResource myMediaTransportControlsStyle}">
</MediaTransportControls>
</MediaPlayerElement.TransportControls>
</MediaPlayerElement>
<MediaPlayerElement AreTransportControlsEnabled="True">
<MediaPlayerElement.TransportControls>
<MediaTransportControls>
<Grid>
<...Put any content here like textblocks and buttons all this content will be part of controls so they will appear and disappear along with the controls, this Grid covers all the area on the screen ( above the controls bar )...>
</Grid>
</MediaTransportControls>
</MediaPlayerElement.TransportControls>
</MediaPlayerElement>

RichEditBox text wrapping UWP

I am trying to get a RichEditBox to take over the entire width of the app window and to be responsive to window resizing, so far the code I have is the following:
<RichEditBox HorizontalAlignment="Stretch"
TextWrapping="WrapWholeWords"
Height="250"
Name="Intro"/>
What I am getting from the code above is this:
Any ideas on how can I get this to work? Why is it that I tell the text to wrap and it doesn't follow?
UPDATE
I also tried this:
<RichEditBox HorizontalAlignment="Stretch"
Height="250"
Name="Intro"/>
But the result is:
The problem that I am having is that it seems that HorizontalAlignment="Stretch" does not really do anything. The only way I am able to set a decent width is by hard-coding it, for example: Width="600". But if I do this my UI will not respond correctly to resizing. I also tried HorizontalContentAlingment="Stretch" but the result is exactly the same.
How can I get my RichEditBox take up all the available Width and Wrap at the same time?
If you look at the documentation of RichEditBox.TextWrapping, you'll notice that WrapWholeWords is invalid. You have to use
<RichEditBox TextWrapping="Wrap"/>
-or-
<RichEditBox TextWrapping="NoWrap"/>
Since Wrap is the default value, you can drop the property.
<RichEditBox HorizontalAlignment="Stretch"
Height="250"
Name="Intro"/>
Edit: in reply to the updated question:
A control only takes the width of it's parent control. Some container controls (e.g. Grid) automatically take the full width available, while others (e.g. StackPanel) only take the required size of it's children. Using HorizontalAlignment="Stretch" in combination with a StackPanel as a parent control, will only use the MinWidth property instead of the full available width on your screen. Sometimes you can't directly see this issue, e.g. when your control is inside an itemtemplate of a ListView. Use the Live Visual Tree in Visual Studio to find the parent containers and locate the issue.
So in short: make sure your RichEditBox is inside a Grid (or similar control) instead of a StackPanel.

C4F RoundButton content appears on image

Tried adding a Coding4Fun RoundButton to my WP8 XAML. Looked around and copied from samples (i.e. this site), but despite the nice images I see everywhere, the text is displayed on top of my icon:
The XAML code is:
<c4f:RoundButton x:Name="buttonShrtn" Click="buttonShrtn_Click" ImageSource="Assets/Images/icon-button-32.png" FontSize="18" Content="Shrtn" VerticalAlignment="Center" HorizontalAlignment="Right"/>
I just can't find a similar case anywhere. Could there be something else in my XAML that can cause this?
You have to use Label instead of Content.
EDIT
RoundToggleButton, RoundButton, OpacityToggleButton, Tile, and ImageTile content property shifted to Label property. (geekchamp)
Toolkit description.

How do you apply shadows to controls in xaml for Windows 8(RT)

I see that most of the WPF stuff use for example DropShadowEffect, but my xaml in WinRT doesn't recognize that, is there something else to use?
However it's easy to add dropshadow to text. As photoshop dude I immediately released this:
<Grid>
<TextBlock Margin="1,1,0,0" Foreground="<!--Shadow Color-->" Text="Some text"/>
<TextBlock Foreground="<!--Text Color-->" Text="Some text"/>
</Grid>
You are correct, the DropShadowEffect is not available in Windows Store apps.
For now, effects are programmed with DirectX and C++. If you don't want to write your own interop library in C++, check out the sharpdx.org/ library
If you know the Shape of the Control you could create an Image (.png e.g.) with a dropshadow effect towards the outer bounds and include it in the style of the control with the help of Nine-Grid ( http://msdn.microsoft.com/en-us/library/windows/desktop/bb189722.aspx )
(if the dropshadow is 5px wide you can set the margin to -5 and the nine-grid values to 5 to make the shadow appear around the control)
Greetings
You can use DropShadowBitmapEffect to create Shadow effect.
The documentation and an example can be found here.

Sticky header in ListView and GridView WinRT xaml

How could one accomplish behavior in which a header of a ListView or GridView group doesn't scroll with the content, but stays fixed until the content comes to an end and the following header then comes in focus.
The behavior can be observed in Finance app on Windows 8 Release Preview when you scroll through GridView items.
I am not expecting the whole code, but I'd like to hear some ideas, links, code snippets, samples etc. which would help me get started.
Thanks
You might be able to embed a listview in a datatemplate of the main listview. Then you can embed a gridview and gridviewcolumns in the templated listviews and get your column headers that way.
Wrap the ListView in a ScrollViewer. The ListView's internal SrollViewer won't be used, and you'll have control of the outer ScrollViewer, which will allow you to set its TopHeader.
<ScrollViewer>
<ScrollViewer.TopHeader>
... Your header content here ...
</ScrollViewer.TopHeader>
<ListView HorizontalAlignment="Left" VerticalAlignment="Top">
... Your body content here ...
</ListView>
</ScrollViewer>