Silverlight toolkit theme not applied to label - silverlight

Do I have to do something special to the Label control from the Silverlight toolkit to get the current themed applied?
When looking at the Theme Browser on the demo page it appears as though labels should be turning white in the expression dark theme, but it's staying black for me.

it works fine for me. You might have an implicit or explicit Label style that overwrites it.
Edit:
<Grid x:Name="LayoutRoot">
<toolkit:ExpressionDarkTheme>
<Grid>
<sdk:Label Content="label" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</toolkit:ExpressionDarkTheme>
</Grid>

Related

Place control on top of Microsoft.Toolkit.Wpf.UI.Controls.WebView

<Grid>
<!-- xmlns:webview="clr-namespace:Microsoft.Toolkit.Wpf.UI.Controls;assembly=Microsoft.Toolkit.Wpf.UI.Controls.WebView" -->
<webview:WebView ... />
<Grid x:Name="Overlay"
Panel.ZIndex="1000"
Background="Red"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
</Grid>
I am trying to overlay a WebView with another control (Overlay). But it seems that the WebView is always on top of other controls.
Is there a way to place controls on top of a Microsoft.Toolkit.Wpf.UI.Controls.WebView?
The Webview control is a wrapped UWP control which in turn wraps a win32 component I believe.
Due to airspace problems this control will not support transparency and will always be rendered on top. See here for a better description:
https://learn.microsoft.com/en-us/dotnet/framework/wpf/advanced/technology-regions-overview
Although it is possible to run it in a popup as a workaround, it might not be very futureproof:
"WebView controls can be hosted in a popup window. We recommend that you do not do this because support for that scenario will soon be disabled for security reasons."
See here for more
CefSharp might be a better solution. It it based on Chromium and there is a Nuget package available. In the example below a red grid is rendered over the browser:
<Grid>
<cefSharp:ChromiumWebBrowser Address="https://github.com/cefsharp/CefSharp/wiki/Frequently-asked-questions" />
<Grid x:Name="Overlay"
Height="100"
Background="Red"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
</Grid>
Output:

Restoring layout when we use GridSplitter

I am using Gridsplitter control to give the flexibility of resizing the heights of a grid and a tab in a MVVM driven WPF application.
It is working with out any problem, but after I resize the height of any of the controls I navigate to some other screen and comes back to this screen I am losing the changes. The controls are again reset to their default heights.
Can somebody suggest me an efficient way of restoring the changes when we come back ?
This is the code I am using.
<igDP:XamDataGrid Grid.Row="1" Grid.Column="0" DockPanel.Dock="Top" />
<GridSplitter Grid.Row="2" HorizontalAlignment="Stretch"
VerticalAlignment="Center" Height="2"/>
<TabControl Grid.Row="3" Grid.Column="0" DockPanel.Dock="Top">
Thanks in advance.
First it would be nice to see actual code you can do that by pasting some code in your question and the use cyrly brackets under the yellow banner when you start typing ;-).
Secondly It seems like you could use binding with your ViewModel i.e. VM.UserSettings.TabHeight.
and then in .xaml
this is assuming
<Page or Window.DataContext>
<vm:ViewModel />
</Page or Window.DataContext>
<TabControl Height={Binding UserSettings.TabHeight}">
good luck :-)

Why does WP7 ListPicker have different margins and height to TextBox

I have a page in my WP7 app consisting of a TextBox beside a ListPicker. In their default modes, they don't line up properly; the ListPicker has a different padding to the TextBox, and its height is also different.
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<StackPanel Orientation="Horizontal">
<TextBox HorizontalAlignment="Left" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top"/>
<toolkit:ListPicker Width="170" ItemsSource="{Binding l}" Style="{StaticResource ListPickerStyle1}" VerticalAlignment="Top"/>
</StackPanel>
</Grid>
Manually tweaking the ListPicker's template to fit in correctly here is tricky and error prone. For example, when its height is adjusted, the caption (i.e. the text of the selected item) is no longer in the centre of the component.
My app is currently failing MS app review because the components are not all the same height.
Is there an easy way for me to set the toolkit:ListPicker to have the same appearance as a TextBox?
The simplest solution will be to take a copy of the the default style and tweak that using Blend to be exactly how you want it to look. This will take a little trial and error to sort out.
You can then use the implicit styling rules to apply it to all ListPickers without having to explicitly set the style on each instance:
<Style x:Key="MyListPickerStyle
TargetType="toolkit:ListPicker>
.... your tweaks here
</Style>
<Style TargetType="toolkit:ListPicker"
BasedOn="{StaticResource MyListPickerStyle}" />
It may be easier to tweak the TextBox Style of course :)

Silverlight multiple line textbox

I have looked at several code snippets where people suggest that the AcceptsReturn property of a textbox in Silverlight will enable multiple lines.
My problem however is when I add a textbox with said property and explicity set the height or allow it to fill the container, the text sits vertically in the middle of the textbox.
<Grid x:Name="LayoutRoot" >
<TextBox TextWrapping="Wrap" Text="TextBox" AcceptsReturn="True"/>
</Grid>
I need the text to anchor to the top of the textbox.
Ensure there is not an implicit style for the text box which is overriding the default expected behavior in this case. IN my case I was using the Cosmopolitan Theme from Microsoft and it had an implicit style for TextBox elements that did not produce the proper behavior.
In the resources from that theme if you look at the DefaultTextBoxStyle in the CoreStyles.xaml file, at line 448 you will find the ScrollViewer with a VerticalAlignment set to Center. Adjusting this to top solved my problem.
Try this:
<Grid x:Name="LayoutRoot">
<TextBox VerticalAlignment="Stretch" VerticalContentAlignment="Top"
TextWrapping="Wrap" Text="TextBox" AcceptsReturn="True"/>
</Grid>
The text is at the top of the box, and the the box stretches to fill the whole page.

Silverlight Border object not visible when theme applied?

I have a applied one of the Silverlight Toolkit themes to my XAML page, and now for some reason my Border objects don't show up. Is this by design? I've made sure to explicitly state a BorderBrush color that should contrast the theme background, but this does not fix the issue.
In case it helps, the theme I'm using is the BureauBlack theme from the Silverlight Toolkit.
And here is a code snippet of one of my Borders.
<Border VerticalAlignment="Top" Grid.Column="0" Grid.Row="2" Grid.RowSpan="2" BorderBrush="Orange" CornerRadius="10" Margin="0" Height="300">
<StackPanel>
<TextBlock Text="Status Panel" FontSize="20" TextAlignment="Center" />
...
</StackPanel>
</Border>
It looks like when a theme is loaded it loads its own default set of values for most object properties. In this case, the BorderThickness property of the border object defaults to 0. As a result you don't see it.
By explicitly giving the BorderThickness property a value (non-zero ofcourse), I got my border to show up.
In addition, I can recommend Silverlight Spy tool.
One of the feature of Silverlight Spy is to provide a tree of all controls, to display all their properties and to provide an ability to dynamically change them. It greatly decrease time for such problem resolving.
I've used it several times in cases like your.

Resources