I have the following set up for my TextBlock
<TextBox x:Name="SearchTextBlock" InputScope="Search" Opacity="0.999"
Height="Auto" VerticalAlignment="Top"
BorderBrush="{StaticResource ThemeBrush}" BorderThickness="8" />
which yields
But extra space remains around the TextBlock. How might I remove this? Do I need to create a style or can this be done within the TextBlock tag itself?
From the Designer right click on the TextBox and select Edit Template -> Edit a Copy
Choose where do you want to save it and choose it's Key
And then analyzing the code generated you see Margin="{StaticResource PhoneTouchTargetOverhang}"
witch you can play with until you like the result.
TextBox has a theme style applied to it. Things like margin and padding should be fairly consistent between themes. The best way I've found to "override" the style of something (including a TextBox) is the copy the style resource and tweak it. This is easily done with the Document Outline window.
First, make sure the Document Outline window is visible. This can be done with Ctrl+W,U if you use the Visual C# keyboard thread. Or, View\Other Windows\Document Outline.
Next, make sure the control you want to copy the resource from is selected in the Design surface. Then, go to the document outline and you will see the control selected in there. Right-click the control and select Edit Template/Edit a Copy.... This will create a copy of the style resource (defaulting to within you page XAML. but you have the option of other destinations.). You can then edit that private resource to your heart's content.
In terms of the amount of space around the TextBox, look for things like "MainBorder" in that style.
Update:
verdesrobert's method of getting a copy of the style is much quicker than mine :). Learn something new every day!
Related
As per the title, what is the most efficient way to make use available XAML UI elements to display a lot of [selectable, non-modifiable] texts being appended regularly? Think of dumping out logging information or big HTML page as they are downloaded.
The TextBox does not seem to be very efficient since the only way to change the text is to set its Text property which is a Platform::String. There is no efficient way to append Platform::String repeatedly since I believe that the Platform::String(const wchar_t *) constructor copies the input string internally so even if I try to use string buffer, it doesn't help.
As for the other text control RichEditBox, I have no idea how to use it within a DataTemplate. (I need the control to be elements of a ListView.)
You can display the logs as items of a ListView or ItemsControl and display each as simple TextBlock with selectability:
<TextBlock IsTextSelectionEnabled="True" ... />
This is the most efficient approach you can get, as the list provides virtualization and TextBlock has minimal overhead as compared to TextBlock and RichEditBox and is read-only.
I have a TextBox inside a RelativePanel in a universal Win App in C# (XAML/vs2015).
I want the textbox to be always on the right end of the panel, even when the form size changes.
Please tell me how to do that
thank you
Well since the generic answer did the trick without needing any further detail, might as well enter it as an answer so other viewers know you got sorted and skip the question.
Since it's a child of the RelativePanel you need to supply the declaration to the element, in this case TextBox using the bool property set to true of;
RelativePanel.AlignRightWithPanel="True"
Glad you got a remedy, have a great weekend!
I am trying to change the background, pressed state background and color of selected date, time values in ComboBox (that is currently Accent color). The problem is that when I apply the default template available at msdn here and here.
My control changes such that each value in these boxes now have different ComboBox instead of just one. Like in the following image (day, month, year have different ComboBox).
(Image is only for reference)
Also some of the theme resources are missing too like
Foreground="{ThemeResource TimePickerHeaderForegroundThemeBrush}"
Margin="{ThemeResource TimePickerHeaderThemeMargin}"
FontWeight="{ThemeResource TimePickerHeaderThemeFontWeight
This is how my control look like at the moment without styling applied
Here is the code I am using
<DatePicker x:Name="Date_Picker"
Header="Date:"
Background="{StaticResource HotPink}"
Foreground="{StaticResource Gray05}" />
<TimePicker x:Name="Time_Picker"
Header="Time:"
MinuteIncrement="5"
Background="{StaticResource HotPink}"
Foreground="{StaticResource Gray05}"/>
One more issue is that pink background is only visible on DatePicker and not on TimePicker which is very weird.
You should edit the templates of the controls. Open the project in Blend and find the element in the Document Outline. Right-click and select Edit Template > Edit a Copy... (see picture below). This will generate a copy of the default template. From this you can edit the different visual states (which determine how the control will look in different states: active/hover/disabled/etc). When you set the custom values here, they should work as expected.
Screenshot from Blend for VS2015
I am wanting to add an image to the top or background of a listbox. I would like it to be visible on the screen, but more importantly is that it prints. Can someone help me with the code for this. I tried to see if you could add it through properties and don't see that option. I need the listbox not listview. Also I was wondering if it could be added as a string and the file referenced at the top of the listbox (when you right click the little arrow and click edit options? Can someone please help. I am working on a project and still very new at this.
You need to create a custom ListBox class and add the ability to draw a custom background by overriding the OnPaint event, like on:
Source: http://www.vbforums.com/showthread.php?416784-2005-ListBox-Background-Image
In my application i am using MultiselectList for selecting a list of student information. Here my issue is that, I am using a black background image for my page,
Because of this in white theme, the checkbox portion is invisible. I try to edit the template of checkbox item in Blend, but failed, while editing the template its populating a huge chunk of code in XAML.
While editing template instead of style its generating Template (I edited the Multilist Item using Blend).
In the real application i am using itemtemplate and assign the resource to this item template.
So I don't know where to assign this template, and where to edit in that template to change my checkbox colour, this is a blocker issue for me, my friend told me that without theme support the app won’t pass market place submission.
Doing what you want to do, ie. editing the color of the checkbox, depending on the theme and background selected would be too much work. Have you tried using the default styles that come with Silverlight? For example, In this case, PhoneContrastbackgroundColor would be a good choice.
XAML code
<DataTemplate x:Key="whatever">
<TextBlock Text="ItemName"/>
<CheckBox BackgroundColor="{StaticResource PhoneContrastbackgroundColor}"/>
</DataTemplate>