I'm not sure if what i want is even possible, but here we go. I have multiple stackpanels with multiple lines in them As shown in the following code:
<StackPanel Orientation="Vertical" Margin="700,75,0,0">
<Border>
<TextBlock OpticalMarginAlignment="None">
<Run FontSize="24" Text="Product"></Run><LineBreak/>
<Run FontSize="18" Text="Artikelnummer: "></Run><Run FontSize="18" Text="{Binding ItemNo}"></Run><LineBreak/>
<Run FontSize="18" Text="Omschrijving: "></Run><Run FontSize="18" Text="{Binding Description}"></Run>
</TextBlock>
</Border>
</StackPanel>
<StackPanel Orientation="Vertical" Margin="700,175,0,0">
<Border>
<TextBlock OpticalMarginAlignment="None">
<Run FontSize="24" Text="Prijzen"></Run><LineBreak/>
<Run FontSize="18" Text="Inkoop prijs: "></Run><Run FontSize="18" Text="{Binding PurchasePrice}"></Run><LineBreak/>
<Run FontSize="18" Text="Prijs excl BTW: "></Run><Run FontSize="18" Text="{Binding UnitPriceExclVAT}"></Run><LineBreak/>
<Run FontSize="18" Text="Marge: "></Run><Run FontSize="18" Text="{Binding Margin}"></Run>
</TextBlock>
</Border>
</StackPanel>
<StackPanel Orientation="Vertical" Margin="700,300,0,0">
<Border>
<TextBlock OpticalMarginAlignment="None">
<Run FontSize="24" Text="Extra informatie"></Run><LineBreak/>
<Run FontSize="18" Text="Eenheid: "></Run><Run FontSize="18" Text="{Binding UnitOfMeasure}"></Run><LineBreak/>
<Run FontSize="18" Text="Actuele voorraad: "></Run><Run FontSize="18" Text="{Binding ActualStock}"></Run><LineBreak/>
<Run FontSize="18" Text="Levertijd: "></Run><Run FontSize="18" Text="levertijd"></Run>
</TextBlock>
</Border>
</StackPanel>
As you can see i put 2 texts behind each other. Now i want to allign the second text which start with {Bindin"} all below each other (i hope you understand what i want) Now its shown like this:
header panel 1.
Text1: binding text
longerText1: binding text
evenLongerText1: binding text
header panel 2.
Text2: binding text
longerText2: binding text
evenLongerText2: binding text
But i want this:
header panel 1.
Text1: 'binding text'
longerText1: 'binding text'
evenLongerText1: 'binding text'
header panel 2.
Text2: 'binding text'
longerText2: 'binding text'
evenLongerText2: 'binding text'
Any idea how i can accomplish my goal without just adding spaces (since that will not align nicely)?
Thanks in advance!
Edit: oh i see it doesn't care about my enters and white spaces. let me fix that.
Edit 2: i can't fix it. and can't upload a picture (no 10 rep)
Basically i want every {binding text} to allign nicely.
Related
I have TextBlock in which I put 2 Inlines (Runs), the HorizontalAlignment of the TextBlock is set to Center, this is ok, I just want to center the first Run comparing to the second, here's my code :
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="/Throne;component/Fonts/#Segoe UI Light" FontSize="35" FontWeight="Bold" Visibility="{Binding UserNameTextBlockVisibility}">
<Run FontSize="25">En tant que :</Run>
<LineBreak />
<Run Text="{Binding UserName}" Foreground="ForestGreen"/>
</TextBlock>
Here's the result I get :
What I want to achieve :
I tried to search around the documentation and in threads on the internet, but I didn't really find a way to achieve this, how can I realize that ?
Set TextAlignment="Center" on your TextBlock
<TextBlock TextAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="/Throne;component/Fonts/#Segoe UI Light" FontSize="35" FontWeight="Bold" Visibility="{Binding UserNameTextBlockVisibility}">
<Run FontSize="25">En tant que :</Run>
<LineBreak />
<Run Text="{Binding UserName}" Foreground="ForestGreen"/>
</TextBlock>
I have a little problem using the longlistselector (well more specifically the multilonglistselector) in windows phone 8.
I use binding to bind the name of an object to the items, the XAML code is as follow:
<Grid>
<TextBox x:Name="searchBox"
IsEnabled="{Binding IsConnected}"
HorizontalAlignment="Left" KeyUp="CheckKey"
Height="72" Margin="10,10,0,0" TextWrapping="Wrap" InputScope="Search" GotFocus="Select"/>
<toolkit:LongListMultiSelector EnforceIsSelectionEnabled="True" SelectionChanged="AdjustAddSelectionButton" x:Name="resultList" ItemsSource="{Binding Results}" HorizontalAlignment="Stretch" Height="434" Margin="10,87,0,0" VerticalAlignment="Top" >
<toolkit:LongListMultiSelector.ItemTemplate>
<DataTemplate>
<Grid>
<TextBlock Text="{Binding Title}" TextWrapping="Wrap">
<toolkit:GestureService.GestureListener>
<toolkit:GestureListener DoubleTap="OpenArticleDetail" />
</toolkit:GestureService.GestureListener>
</TextBlock>
</Grid>
</DataTemplate>
</toolkit:LongListMultiSelector.ItemTemplate>
</toolkit:LongListMultiSelector>
</Grid>
The Binding takes place perfectly, but the text is sometimes too long and doesn't fit the screen. How would I go about wrapping this text to another line?, I 'll give a screenshot here
You didn't really state any specific problem or question you want answered. Please try to be a bit more clear in the future.
If you don't like that the TextBlock cuts off words that it can't fit, then you have several solutions.
TextBlocks have a TextWrapping property, so doing TextWrapping="Wrap" will enable the TextBlock to resize itself to display all the content.
TextBlocks have the TextTrimming property, so writing TextTrimming="WordEllipsis" will replace any cut off words with an ellipsis.
If you want to keep the one line but also show all the content, you can put the TextBlock inside a Horizontal ScrollViewer, which will let the user scroll the text left and right. Not great, but a decent solution
Code for 3.
<ScrollViewer ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Visible">
<TextBlock Text="Text"/>
</ScrollViewer>
I added a huge right padding to my main TextBlock to work around this issue.
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Key="MyTemplate">
<StackPanel VerticalAlignment="Top" Margin="0,-4,-50,0">
<TextBlock FontWeight="Bold" FontSize="18" Text="{Binding title}" TextWrapping="Wrap" Margin="0,0,0,6"/>
<TextBlock Text="{Binding text}" TextWrapping="Wrap" FontSize="30" Padding="0,0,125,0"/>
<Rectangle HorizontalAlignment="Stretch" Height="1" Fill="#78c5a6" Margin="0,18,0,18"/>
</StackPanel>
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
I am wondering why my webbrowser doesn't redirect to my html page.
I have a linkbutton on my xaml page with a tap event and i'm creating my object webbrowser when i load first the page.
This is the code I am using :
private void web_Tap(object sender, GestureEventArgs e)
{
wbbrowser.Navigate(new Uri("http://mywebsite.com/index.html", UriKind.Absolute));
}
This is the Xaml i am using :
<controls:PanoramaItem Header="about me">
<!--Double line list with text wrapping-->
<StackPanel Margin="0,0,0,17" Width="432" Height="483" >
<Rectangle Height="186" Width="150" Margin="-250,0,9,10" >
<Rectangle.Fill>
<ImageBrush ImageSource="Img/id.jpg"></ImageBrush>
</Rectangle.Fill>
</Rectangle>
<TextBlock Text ="Name" TextWrapping="Wrap" Margin="12,-6,12,10" Style="{StaticResource PhoneTextExtraLargeStyle}"/>
<TextBlock Text="age" TextWrapping="Wrap" Margin="12,-6,12,10" Style="{StaticResource PhoneTextSubtleStyle}"/>
<TextBlock Text="nationality" TextWrapping="Wrap" Margin="12,-6,12,10" Style="{StaticResource PhoneTextSubtleStyle}"/>
<TextBlock Text="adress" TextWrapping="Wrap" Margin="12,-6,12,10" Style="{StaticResource PhoneTextSubtleStyle}"/>
<TextBlock Text="phone" TextWrapping="Wrap" Margin="12,-6,12,10" Style="{StaticResource PhoneTextSubtleStyle}"/>
<TextBlock Text="email" TextWrapping="Wrap" Margin="12,-6,12,10" Style="{StaticResource PhoneTextSubtleStyle}"/>
<TextBlock Text="others" TextWrapping="Wrap" Margin="12,-6,12,10" Style="{StaticResource PhoneTextSubtleStyle}"/>
<HyperlinkButton Name="web" Content="web version" Margin="12,-6,12,10" Tap="web_Tap"></HyperlinkButton>
</StackPanel>
</controls:PanoramaItem>
So I am actually not declaring the Phone:WebBrowser.
I just create my object at the main page loaded .
First, you are using the HyperlinkButton the wrong way. You need to add a TargetName="NAME_OF_TARGET" for it to navigate. Second, use the NavigateUri property to navigate to a page instead of handling the tap.
This has been described in the MSDN documentation article.
I want to 1. from the following image:
My code is here:
<WrapPanel>
<TextBlock Text="Title: " Style="{StaticResource Title}" TextWrapping="Wrap" />
<TextBlock Text="{Binding Description" Style="{StaticResource Normal}" TextWrapping="Wrap" />
</WrapPanel>
But if Description text is short, shown like 2., if Description text is long, shown like 3.
How to do this like 1.?
I have solve my question using Run:
<TextBlock TextWrapping="Wrap">
<Run Text="Title: " Style="{StaticResource TitleRun}"/>
<Run Text="{Binding Description,Mode=OneWay}" Style="{StaticResource NormalRun}"/>
</TextBlock>
Just keep adding them to the Grid with 2 columns and n number of rows, adding new rows/colls as you add them.
You can create a behaviour for that.
Given the below TextBlock, how do I make the SomeString part of the text bold?
<TextBlock Text="{Binding SomeString,StringFormat='{}Row: {0}'}" />
ie: If SomeString = "ABC" I want the TextBlock to look like this:
Row: ABC
Try something like this
<StackPanel Orientation="Horizontal">
<TextBlock Text="Row:"/>
<TextBlock FontWeight="Bold" Text="{Binding SomeString}"/>
</StackPanel>
Basically, you could format each individual Run inside the same TextBlock.
Through XAML
<TextBlock>
<Run>Row:</Run>
<Run FontWeight="Bold" Text="{Binding SomeString}"></Run>
</TextBlock>
MSDN Section
Hope this helps.