I'm developing WinRT / windows store app.
Is there any way how i could highlight certain text in TextBlock?
something like that:
<controls:TextBlockHighlight Text="{Binding Text}" HighlightText="{Binding HighlightText}" />
I managed to get required output with
<TextBlock>
<TextBlock.Text>
<Run>......</Run>
</TextBlock.Text>
</Textblock>
But i need that control to be bindable, and i don't how to make it like that..
Filip,
Many thanks for addition in framework.
Highlight textblock behavior is now available in http://winrtxamltoolkit.codeplex.com/
Regards
Related
I have an app with a dropdownbutton flyout. I'm migrating the XAML over to a new project and the dropdownbutton is behaving differently. In the first instance, the dropdown flyout would be alligned to the left edge of the button (what I want it to do). In the second instance, it is aligned to the right edge of the button and contained within the apps window.
XAML
<DropDownButton ToolTipService.ToolTip="File"
VerticalAlignment="Top"
HorizontalAlignment="Left" Background="Transparent"
Style="{StaticResource CommandBarFlyoutEllipsisButtonStyle}"
Height="33"
FontFamily="Segoe MDL2 Assets" Content="">
<DropDownButton.Flyout>
<MenuBarItemFlyout Placement="LeftEdgeAlignedTop">
<MenuFlyoutItem Text="Open File" Icon="OpenFile" Tag="Open File"
Click="OpenLocalFile"/>
</MenuBarItemFlyout>
</DropDownButton.Flyout>
</DropDownButton>
First app (how I want it to look)
Second app
There are a number of differences between the two apps but the xaml is almost identical. I can't seem to pinpoint what could cause this fly out to behave differently. Thanks for any help you can provide!
What I'm trying to do was extremely easy in SL/WP 8 but seems to be impossible in WP 8.1 without redefining the Hub template myself. I want to create a hub with a header that:
Scrolls horizontally.
Has a background that scrolls along with it.
Has no margins on either side.
I know this can probably be solved by just having my background image include the background and the hub just being transparent, but I wanted to know if there was a way to solve it in XAML.
Putting a Grid with a background into the Hub's header just highlights the background as much as the hub needs--not stretching all the way across:
<Hub>
<Hub.Header>
<Grid Background="Red" Height="60">
<TextBlock Text="My Header" />
</Grid>
</Hub.Header>
</Hub>
The above makes the header with the text "My Header" but only the text part has a background. Furthermore, the Hub itself seems to have inner margins of 16 on each side so the background doesn't stretch across the whole phone screen.
Should I just be going with a background or deconstructing the template to remove the margins?
Far from an elegant solution but basically I put the background outside the Hub and gave it negative margins like so. Hacky but I guess it works.
<Grid>
<!-- This is the header bar -->
<Grid Height="64" Background="Red" />
<Hub>
<Hub.Header>
<StackPanel Margin="-6,0,0,0">
...
</StackPanel>
</Hub.Header>
<!-- actually just defined the margin in my ResourceDictionary to target all HubSections -->
<HubSection Header="section 1" Margin="-2,-20,-4,8" />
<HubSection Header="section 2" Margin="-2,-20,-4,8" />
</Hub>
</Grid>
I need to prevent the TextBlock from changing the color of special characters, it looks like the WP TextBlock recognizes some shapes as emojis and colors them but it seems there is no way to control it like in Windows 8 like this article says:
http://blogs.windows.com/windows/b/appbuilder/archive/2013/11/11/xaml-text-improvements-in-windows-8-1.aspx
http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.textbox.iscolorfontenabled.aspx
There is no IsColorFontEnabled in WP, anyone knows how to override this behavior?
The problem is with the heart character ♥, and I would not want to use a list of heart shape paths
EDIT: I have used the ❤ character but has different spacing and coloring than the normal one, I think the only way is to use a list of paths with this shape :(
Thanks
You can make the RichTextBox act like the TextBlock by setting the IsReadOnly property to true. It looks similar to the TextBlock, while the TextBox doesn't.
I'm not sure if you can control the emoji problem with this idea, you'd have to test, but it does allow you have full control over the color of text.
XAML
<StackPanel x:Name="ContentPanel"
Grid.Row="1"
Margin="12,0,12,0">
<!-- One Color-->
<RichTextBox Foreground='White'>
<Paragraph>Text with ☻</Paragraph>
</RichTextBox>
<!-- Multi color -->
<RichTextBox IsReadOnly='True'>
<Paragraph>
<Run>Mixed Colors.</Run>
<Run Foreground='Red'
FontWeight='Bold'>☺</Run>
<Run Foreground='Yellow'>☻</Run>
<Run Foreground='LightGreen'>♫</Run>
</Paragraph>
</RichTextBox>
</StackPanel>
Output
I would like to place a GRID element just below another GRID element using XAML just like Android's layout below. How can it be done, if possible?
Is this all you're looking for?
<StackPanel>
<Grid/>
<Grid/>
</StackPanel>
I have a silverlight application in which I display items in a list box.
I want to hide some items based on a condition, like some value of a string.
My xaml looks like this:
<ListBox
ItemsSource="{Binding DashboardTypes}"
SelectedItem="{Binding SelectedDashboardCategory,Mode=TwoWay}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
Style="{StaticResource ListBoxStyleAttribute}"
Margin="2"
ItemContainerStyle="{StaticResource ListBoxItemStyle}" />
You'll need to set up an ItemTemplate to describe your items and then add a binding on that for the Visibility property that controls when items are visible or not. I suspect that you'll need a converter to actually implement the rule for when an item should be visible.
There is a Stack Overflow question that covers something similar but in WPF. It should give you some pointers that will help you in implementing this.