How can I change the length of the NavigationViewItem selection underline to match the item content text in a WinUI3 app? - navigationview

I have not seen an example or documentation for a property that lets me change the length of a Windows.UI.Xaml.Controls.NavigationViewItem blue selector line to be the length of the content text. The blue selector is very short by default. Here is a code snippet:
<NavigationView Grid.Row="0" Grid.Column="1" Loaded="NavigationView_Loaded"
ItemInvoked="NavigationView_ItemInvoked"
BackRequested="NavigationView_BackRequested"
IsBackButtonVisible="Collapsed"
IsBackEnabled="false"
PaneDisplayMode="Top">
<NavigationView.MenuItems>
<NavigationViewItem Tag="basics" Content="Window Basics"></NavigationViewItem>
<NavigationViewItem Tag="presenters" Content="Presenters"></NavigationViewItem>
<NavigationViewItem Tag="configs" Content="Window Configurations"></NavigationViewItem>
<NavigationViewItem Tag="titlebar" Content="TitleBar"></NavigationViewItem>
</NavigationView.MenuItems>
</NavigationView>
Is there a property that lets me adjust the selector length or automatically stretches it to fit the content? For example, in the xaml snippet above, I would like the selection line to fit the length of the text "Window Basics" when the first item is selected.
Hopefully this makes sense. Even the Microsoft samples I've seen (including the Xaml Controls Gallery demo) have the short underlining.
Thanks very much for any assistance.
Robert

I discovered that a simple UWP app with NavigationView does underline the NavigationViewItem contents correctly. That app is using Microsoft.UI.xaml 2.5.
So it may be that the WinUI app I am writing, using Microsoft.WindowsAppSDK 1.0 has a bug.

Related

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.

Ellipsis inside button content Windows Phone

is it possible to get ellipsis inside button when content length increase the width of button.
I tried editing template but did get much success?
You should have some options. If it's just at the instance, you can just plop your content in as TextBlock so something like;
<Button>
<Button.Content>
<TextBlock Text="Blah Blah Blah" TextTrimming="WordEllipsis"/>
</Button.Content>
</Button>
Or if you make a custom style template for Button you could replace the ContentPresenter in it with a TextBlock with it's content bound to the template like Text="{TemplateBinding Content}" and apply your TextTrimming directly to it. Except remember TextTrimming needs a boundary to invoke it, so your Button's may require like a set MaxWidth/Width or its parent panel will have to restrict its size to invoke the trimming.
Hope this helps, Cheers.
PS - This same concept can be used in WP, WPF, Silverlight, whatever really.

Increase width of App bar button in WP8.1

While using the Appbar button in the CommandBar of a Page, content of the Appbar button is fixed it seems. So that the width is not increase based on the Content.
Is there any work around to make visible the whole content or like wrapped content?
Thanks in advance.
<CommandBar BorderBrush="White"
BorderThickness="1"
IsSticky="True">
<CommandBar.PrimaryCommands>
<AppBarButton Icon="Accept" Label="return to yard" />
</CommandBar.PrimaryCommands>
</CommandBar>
It's funny but it depends on your phone's language. I have discovered it in my own app, where one of AppBar buttons has long label. When the language is set to Polish, then the label wraps and has two lines. But in English it has the same problem like you... One line and clipped (first button in screenshots below).
Polish:
English:
The answer to your question is: there is no way to change the size of AppBar buttons or labels. You have to come up with some shorter label...

How to make CheckBox bigger on Windows 8

How to make CheckBox bigger on Windows 8 ?
I already know about LayoutTransform, but looks like there is not this property on Windows 8:
<CheckBox>
<CheckBox.LayoutTransform>
<ScaleTransform ScaleX="2" ScaleY="2" />
</CheckBox.LayoutTransform>
</CheckBox>
Several ways:
You can increase the overall size by applying a render transform. This will double the height and width during rendering. It may not lay out as you want.
<CheckBox RenderTransformOrigin="0.5,0.5" >
<CheckBox.RenderTransform>
<CompositeTransform ScaleX="2" ScaleY="2"/>
</CheckBox.RenderTransform>
</CheckBox>
You can use a ViewBox, which will lay out in the same spot but won't give full control over the size
<Viewbox Height="100">
<CheckBox>
</CheckBox>
</Viewbox>
Or you can edit the template. This is the most code, but most will be generated for you if you select a checkbox in the designer, right click, and choose "Edit template...". It will provide the most control and you can completely swap out the Checkbox's elements. MSDN's Quickstart: Control templates demonstrates changing a Checkbox's template. Depending on the exact look you'll want you'll probably need to increase the sizes of all of the sub-elements (NormalRectangle, CheckGlyph, IndeterminateGlyph, FocusVisualWhite, and FocusVisualBlack).

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.