What should I do to see all the content in label? I already used Textblock but I can't still see it's full content...
I am new in WPF so I still don't know what should I do with this problem.
this is my code behind:
lblFExtension.Content = "Type of File: " + fInfo.Extension;
lblFName.Content = "File Name: " + fInfo.Name;
lblFLocation.Content = "File Location: " + fInfo.Directory;
lblFSize.Content = "File Size: " + Convert.ToString(fileSizeConversion(fInfo.Length));
<TextBlock Height="49" Margin="304,127,53,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top"/>
adjust your texblock height and then give TextWrapping="Wrap".it will work.Before this you have to check texblock margin
You can use a TextBlock and enable TextWrapping like that:
<TextBlock TextWrapping="Wrap"><![CDATA[
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed neque et tellus tincidunt interdum. Morbi diam eros, imperdiet at, volutpat et, vestibulum quis, sem. Curabitur eu tellus vel felis molestie malesuada. Pellentesque nec lacus. Aenean fringilla nonummy sapien. Morbi eu odio at turpis cursus tristique. Integer nec lectus sit amet turpis bibendum feugiat. Cras posuere condimentum sapien. Vivamus accumsan, lacus at bibendum vehicula, magna elit consectetuer diam, ac luctus elit diam non leo. Vestibulum lobortis augue nec nisl. Fusce viverra purus consequat lacus. Nullam elementum mattis tellus. In hac habitasse platea dictumst. Aliquam ac velit sit amet urna placerat fringilla. Fusce mattis arcu eget urna. Sed lacus.]]></TextBlock>
It might be that you need to rethink your design, as it might look strange when a value breaks and it has a label. So you could think of splitting the label (eg File name:) and value into two definitions and arrange them accordingly.
Related
I currently have two views for an app, "about" and "work." Both pages are in a horizontal scroll view that snaps to feel like a page.
The only problem is when there is a lot of content on one page the other page stretches to be as large which causes there to be a lot of blank space at the bottom.
Here is an example of what I'm talking about.
"About" and "Work Pages
<scrollview>
<View>
//small content
</View>
<View>
//large content
</View>
</scrollview>
You need to wrap the content of each page with a div that has the same height.
.horizontal-pages {
width: 300px;
max-height: 400px;
display: flex;
flex-direction: column;
}
.page-slider {
display: flex;
flex: auto;
overflow: hidden;
}
.page-wrapper {
width: 100%;
height 100%;
overflow: auto;
}
<body>
<section class="horizontal-pages">
<div class="page-header">
page header
</div>
<div class="page-slider">
<div class="page-wrapper">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam nisi sem, congue eu diam sit amet, malesuada commodo elit. Ut semper ante id lacus faucibus luctus. Mauris vitae turpis et quam blandit eleifend. Nam laoreet lacus vel egestas molestie. Pellentesque vulputate lacus id orci rutrum dapibus. Proin maximus ligula sit amet justo fringilla volutpat. Integer porta posuere tempus. Aliquam semper blandit est in faucibus.</p>
<p>Morbi vel metus lorem. Aliquam sapien massa, tempus in vehicula eu, sodales vitae magna. Sed vel rhoncus purus, tristique egestas nisi. Sed cursus nulla elit, nec malesuada augue facilisis sit amet. Morbi placerat euismod magna sit amet euismod. Duis quis feugiat massa, quis scelerisque mi. Curabitur eu quam pretium, auctor metus posuere, bibendum libero. Donec eu diam lectus. Sed pellentesque porttitor leo. Curabitur iaculis neque vel dignissim finibus. Vestibulum placerat sollicitudin dictum. Donec dignissim pharetra leo et finibus. Curabitur venenatis ligula a elit laoreet, id facilisis augue ultricies.</p>
<p>Aliquam volutpat enim quis ante vehicula faucibus. Fusce aliquet laoreet malesuada. Morbi tristique nibh sit amet nunc posuere, non facilisis velit venenatis. Aliquam id finibus elit, vitae auctor metus. Ut mollis ex vitae metus placerat condimentum. Donec consequat dapibus accumsan. Nullam mollis dui odio, et pharetra urna auctor non.</p>
<p>Sed sed tellus eu nunc scelerisque mattis. Suspendisse leo dui, congue vitae euismod quis, iaculis et enim. Interdum et malesuada fames ac ante ipsum primis in faucibus. In ac condimentum ex. Curabitur tristique velit purus, eget tempus tortor posuere sodales. Nullam vestibulum felis id quam ullamcorper pharetra. Nunc at ultricies purus. Maecenas molestie magna id faucibus lacinia. Vivamus consequat gravida eros, nec pharetra turpis interdum iaculis. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nam feugiat mauris arcu, vel auctor eros faucibus at. Aliquam tincidunt est non arcu sodales aliquet.</p>
<p>Donec tristique tempor sapien vel vestibulum. Nulla eleifend gravida congue. Donec feugiat arcu sit amet odio posuere, eu lacinia ex iaculis. Fusce a mollis ligula. Donec varius, purus in gravida iaculis, est risus posuere ante, quis tincidunt purus velit sodales ante. Ut ut nulla ligula. Cras enim neque, feugiat dignissim urna pretium, cursus condimentum justo. Praesent mauris quam, vehicula at sem id, sodales consectetur tellus. Suspendisse quis magna rhoncus, dapibus ipsum vel, vulputate lacus. Fusce molestie dui neque, eu iaculis augue porta in. In faucibus interdum massa, et tempor lorem imperdiet a. Aenean sed nulla porttitor, maximus massa eget, pulvinar orci. Suspendisse non volutpat leo, in feugiat dui. Vestibulum eu suscipit purus, in suscipit leo. Nam urna mauris, efficitur vitae commodo non, mollis facilisis massa.</p>
</div>
<div class="page-wrapper">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam nisi sem, congue eu diam sit amet, malesuada commodo elit. Ut semper ante id lacus faucibus luctus. Mauris vitae turpis et quam blandit eleifend. Nam laoreet lacus vel egestas molestie. Pellentesque vulputate lacus id orci rutrum dapibus. Proin maximus ligula sit amet justo fringilla volutpat. Integer porta posuere tempus. Aliquam semper blandit est in faucibus.</p>
<p>Morbi vel metus lorem. Aliquam sapien massa, tempus in vehicula eu, sodales vitae magna. Sed vel rhoncus purus, tristique egestas nisi. Sed cursus nulla elit, nec malesuada augue facilisis sit amet. Morbi placerat euismod magna sit amet euismod. Duis quis feugiat massa, quis scelerisque mi. Curabitur eu quam pretium, auctor metus posuere, bibendum libero. Donec eu diam lectus. Sed pellentesque porttitor leo. Curabitur iaculis neque vel dignissim finibus. Vestibulum placerat sollicitudin dictum. Donec dignissim pharetra leo et finibus. Curabitur venenatis ligula a elit laoreet, id facilisis augue ultricies.</p>
</div>
</div>
<div class="page-footer">
page footer
</div>
</section>
</body>
I was able to more or less get what I was looking for. I set a conditional for the content in the large view to only show when the scroll was > 0. That way the smaller view isn't stretched when the other view isn't visible
I am unable to read the HTML tags used in content of JSON file in my react app..
The JSON file :
[{
"_id": 9,
"title":"Text 9",
"subheader":"Dummy header 9",
"images": "images/four-1.png",
"imagesmob" : "images/four-1.webp",
"content":"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent nec velit consectetur, pretium risus vel, eleifend tortor. Integer enim nulla, iaculis sit amet leo vel, sagittis maximus leo. Aliquam semper sapien bibendum nulla consectetur, ut eleifend arcu accumsan. Duis consequat diam sed dolor convallis semper. Ut justo mauris, accumsan non tempus ut, ultrices at tellus. Quisque a sapien urna. Maecenas tempor consequat sollicitudin. Nullam volutpat a eros sit amet vestibulum. Cras sollicitudin vitae urna nec varius. Etiam nec facilisis urna.</p> <p>Donec ut dui condimentum, tincidunt tellus vitae, interdum lorem. Phasellus eget pretium enim. Morbi accumsan turpis vitae turpis venenatis ullamcorper. Proin pretium nisi nec nulla faucibus, a hendrerit turpis malesuada. Nullam id faucibus metus, id faucibus metus. Donec et massa suscipit, congue tortor non, ultricies turpis. Aliquam venenatis massa velit, id ornare ante efficitur vitae. Vivamus id dui tortor. Pellentesque sem mi, bibendum a orci hendrerit, mollis eleifend eros. Nunc sodales orci purus. Vivamus molestie porta egestas. <p>Suspendisse convallis mi ullamcorper, dapibus nisi a, semper felis. Praesent ut lacus eu neque vestibulum efficitur.<\/p> Sed dolor magna, mattis a ultricies vel, <b>tincidunt<\/b> eget enim.<\/p>"
}
]
The react file
<Card variant="outlined" sx={{ maxWidth:345, borderRadius: '11px' }} elevation={3}>
<CardMedia
component="img"
height="194"
image={welcom.images}
alt="Home Page"
/>
<CardHeader
titleTypographyProps={{fontSize: 18, fontWeight: 'bold', color: 'purple' }}
title = {welcom.title}
subheader = {welcom.subheader}
/>
<CardContent>
<div>{welcom.content}</div>
</CardContent>
</Card>
In this when I am trying to read content from the json file , i am unable to get the text which is bold or paragraphs are also not coming. Any help.
You cannot render the raw html in React. For that you can use the dangerouslySetInnerHTML attribute, but you should be careful before using this attribute. As per reactjs document,
dangerouslySetInnerHTML is React’s replacement for using innerHTML in the browser DOM. In general, setting HTML from code is risky because it’s easy to inadvertently expose your users to a cross-site scripting (XSS) attack. So, you can set HTML directly from React, but you have to type out dangerouslySetInnerHTML and pass an object with a __html key, to remind yourself that it’s dangerous.
I have created based on your code.
I'm using this directive to implement a read-more in my ionic app.
My HTML looks like this:
<ion-list>
<ion-item class="item item-thumbnail-left item-text-wrap" ng-repeat="sh in schedule_hosts" type="item-text-wrap">
<img ng-src={{sh.imageURL}}>
<h2>{{sh.firstName}} {{sh.lastName}}</h2>
<p>{{sh.profession.EN}}</p>
<p read-more ng-model="content" words="true" length="5"></p>
</ion-item>
</ion-list>
And in my controller:
$scope.content = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi commodo, ipsum sed pharetra gravida, orci magna rhoncus neque, id pulvinar odio lorem non turpis. Nullam sit amet enim. Suspendisse id velit vitae ligula volutpat condimentum. Aliquam erat volutpat. Sed quis velit. Nulla facilisi. Nulla libero. Vivamus pharetra posuere sapien. Nam consectetuer. Sed aliquam, nunc eget euismod ullamcorper, lectus nunc ullamcorper orci, fermentum bibendum enim nibh eget ipsum. Donec porttitor ligula eu dolor. Maecenas vitae nulla consequat libero cursus venenatis. Nam magna enim, accumsan eu, blandit sed, blandit a, eros." +
"Quisque facilisis erat a dui. Nam malesuada ornare dolor. Cras gravida, diam sit amet rhoncus ornare, erat elit consectetuer erat, id egestas pede nibh eget odio. Proin tincidunt, velit vel porta elementum, magna diam molestie sapien, non aliquet massa pede eu diam. Aliquam iaculis. Fusce et ipsum et nulla tristique facilisis. Donec eget sem sit amet ligula viverra gravida. Etiam vehicula urna vel turpis. Suspendisse sagittis ante a urna. Morbi a est quis orci consequat rutrum. Nullam egestas feugiat felis. Integer adipiscing semper ligula. Nunc molestie, nisl sit amet cursus convallis, sapien lectus pretium metus, vitae pretium enim wisi id lectus." +
"Proin at eros non eros adipiscing mollis. Donec semper turpis sed diam. Sed consequat ligula nec tortor. Integer eget sem. Ut vitae enim eu est vehicula gravida. Morbi ipsum ipsum, porta nec, tempor id, auctor vitae, purus. Pellentesque neque. Nulla luctus erat vitae libero. Integer nec enim. Phasellus aliquam enim et tortor. Quisque aliquet, quam elementum condimentum feugiat, tellus odio consectetuer wisi, vel nonummy sem neque in elit. Curabitur eleifend wisi iaculis ipsum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In non velit non ligula laoreet ultrices. Praesent ultricies facilisis nisl. Vivamus luctus elit sit amet mi.";
This works fine, but as you can see, the content is now the same for every item.
I looking for a way to create a read more functionality that allows me to add the text in HTML, like this:
<p read-more ng-model="content" words="true" length="5">{{sh.content}}</p>
I'm very (very) new to Angularjs and Ionic, any help is appreciated!
It seems you looking for directives. The directive is a feature same as web components.
You issue may be solved like that.
read-more-content.html
<p ng-if="content" read-more ng-model="content" words="true" length="length">{{content}}</p>
read.more.content.js
angular.module('App')
.directive('readMoreContent', function () {
return {
restrict: 'E',
transclude: true,
scope: {
content: '=',
length: '='
},
templateUrl: 'app/components/_read-more.html'
};
});
And usage can be similar like that
<read-more-content content="content" length="5"></read-more-content>
My personal advice split your own code in angular on small components/directives. That allow you avoid lot's of headacke in nearest refactoring. I'm looking forward doing something similar to http://bradfrost.com/blog/post/atomic-web-design/ but in angular.
Is it possible in WP8 XAML wrap text around an image? How?
I know this is possible, in more than one way, using WPF.
Like #Jogy recommended, a RichTextBlock can be pretty handy when you throw in some RichTextBlockOverflow in the mix, say something like;
<Grid Background="White" Width="800" Height="800">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<RichTextBlock IsTextSelectionEnabled="True" TextAlignment="Justify"
OverflowContentTarget="{Binding ElementName=FirstOverflowArea}"
TextIndent="12">
<Paragraph>
<Italic>Whoa! An Image!</Italic>
<InlineUIContainer>
<Border Background="Gray">
<Image Source="Some/Image/Path/Pic.png" Height="100" Width="100"/>
</Border>
</InlineUIContainer>
So the idea is, we throw a bunch fluff in here and as it runs out of room,
it flows into our chain of Overflow containers that
we can put wherever and however we want, yay! Nam vitae ligula non ligula suscipit semper.
Duis sed nulla metus, id hendrerit velit. Curabitur dolor purus, bibendum eu cursus lacinia,
interdum vel augue. Aenean euismod eros et sapien vehicula dictum. Duis ullamcorper, turpis
nec feugiat tincidunt, dui erat luctus risus, aliquam accumsan lacus est vel quam. Nunc lacus
massa, varius eget accumsan id, congue sed orci. Duis dignissim hendrerit egestas. Proin ut
turpis magna, sit amet porta erat. Nunc semper metus nec magna imperdiet nec vestibulum dui fringilla. Sed sed ante libero, nec porttitor mi. Ut luctus, neque vitae placerat egestas,
urna leo auctor magna, sit amet ultricies ipsum felis quis sapien. Proin eleifend varius dui,
at vestibulum nunc consectetur nec. Mauris nulla elit, ultrices a sodales non, aliquam ac est. Quisque sit amet risus nulla. Quisque vestibulum posuere velit, vitae vestibulum eros scelerisque
sit amet. In in risus est, at laoreet dolor. Nullam aliquet pellentesque convallis. Ut vel tincidunt nulla. Mauris auctor tincidunt auctor.
</Paragraph>
<Paragraph>
, consectetur adipiscing elit. Sed ac mi ipsum. Phasellus vel malesuada mauris. Donec
pharetra, enim sit amet mattis tincidunt, felis nisi semper lectus, vel porta diam nisi in augue.
Pellentesque lacus tortor, aliquam et faucibus id, rhoncus ut justo. Sed id lectus odio, eget
pulvinar diam. Suspendisse eleifend ornare libero, in luctus purus aliquet non. Sed interdum, sem
vitae rutrum rhoncus, felis ligula ultrices sem, in eleifend eros ante id neque. Vivamus quam lorem,
varius vitae porta mollis, placerat quis est. Aenean eget sagittis massa. Sed tellus turpis,
ullamcorper eget imperdiet vel, faucibus vel nisl. Nunc sed suscipit quam. Vivamus convallis faucibus
dignissim. Fusce sollicitudin, quam vel cursus mattis, nisl velit tristique sapien, ac vestibulum
ante arcu a nisl. Vestibulum commodo gravida ante at tincidunt. Vestibulum in ornare nunc. Nullam ut
lorem vitae dui placerat lacinia sit amet a arcu. Nulla sit amet odio nisi. Praesent erat urna,
venenatis ac adipiscing vel, congue at lectus. Proin ac metus at quam luctus ultricies.
</Paragraph>
</RichTextBlock>
<RichTextBlockOverflow Grid.Column="1" x:Name="FirstOverflowArea"
Margin="10"
OverflowContentTarget="{Binding ElementName=SecondOverflowArea}"/>
<RichTextBlockOverflow Grid.Row="1" Grid.ColumnSpan="2" x:Name="SecondOverflowArea"
Margin="10"/>
</Grid>
Hope this helps, Cheers!
this may be a stupid question... but I have a simple TextBlock nested within a ScrollViewer. When the user scrolls up, the content moves, but then snaps back to default position when you stop scrolling and remove your finger. How can I set up the ScrollViewer so that the textblock stays at the position it was scrolled to, without snapping back?
<ScrollViewer>
<TextBlock Height="500" HorizontalAlignment="Left" Margin="130,529,0,0" Name="statusTextBlock" Text="TextBlock" VerticalAlignment="Top" Width="298" TextWrapping="Wrap" />
</ScrollViewer>
Many thanks!
EDIT:
Based on a suggestion, I wrapped the ScrollViewer in a Grid. This did not help - the text still snaps back to the original position when you release your finger from the scroll action.
<ScrollViewer Margin="130,540,0,0">
<Grid Height="500" >
<TextBlock HorizontalAlignment="Left" Name="statusTextBlock" Text="TextBlock" VerticalAlignment="Top" TextWrapping="Wrap" />
</Grid>
</ScrollViewer>
I did not find such issue with TextBlock here. My device is updated with Mango build and the Windows Phone SDK 7.1 RC is installed in my machine.
Wrap the TextBlock in a Grid, and set the height (if necessary) on the Grid. Also, I wouldn't recommend using a static width for a TextBlock. Specially not when using Wrapping. You're not accounting for future screen sizes, which is a bad thing™.
<ScrollViewer>
<Grid Height="500">
<TextBlock HorizontalAlignment="Left" Margin="130,529,0,0" Name="statusTextBlock" Text="TextBlock" VerticalAlignment="Top" Width="298" TextWrapping="Wrap" />
</Grid>
</ScrollViewer>
Update
I can't re-create your problem. Here's an example that works just fine:
<Grid x:Name="ContentPanel"
Grid.Row="1"
Margin="12,0,12,0">
<ScrollViewer>
<Grid>
<TextBlock Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. In sagittis auctor quam ac dictum. Nam tincidunt nisl id turpis dignissim fringilla. Sed elementum euismod fringilla. Etiam sem sem, congue at euismod ut, blandit vitae metus. Sed venenatis rutrum elit sed vestibulum. Etiam nec tempus massa. Pellentesque leo velit, laoreet nec pulvinar non, tempor et felis. Nunc at pulvinar ipsum. Nullam id lorem id augue viverra elementum sed vitae nibh. Nunc pulvinar purus a est porttitor sit amet rutrum mi eleifend. Praesent vitae urna non est volutpat mattis. Nulla sit amet mollis lectus. In hac habitasse platea dictumst. Duis viverra, lacus ut sollicitudin auctor, lacus velit elementum turpis, a faucibus nibh velit sed ipsum. Vivamus laoreet purus consectetur dui faucibus in ornare lacus congue. Suspendisse laoreet leo laoreet nisl fermentum ut tempus urna placerat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aenean sit amet quam odio. Quisque eu mattis mauris. Maecenas congue diam quis magna dignissim a facilisis lectus aliquam. Nunc tristique odio id velit pretium eu scelerisque velit dictum. Cras eget purus massa. Suspendisse potenti. Duis at egestas nunc. Nullam vehicula urna eget neque interdum pellentesque. Nulla non nisl ipsum. Vestibulum congue viverra felis quis congue. Duis sodales, odio vitae aliquam euismod, dolor augue iaculis quam, non hendrerit felis metus quis purus. Suspendisse fringilla vulputate tellus ac consequat. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Phasellus pulvinar accumsan luctus. Nunc vel orci purus, sollicitudin hendrerit orci. Nam commodo, massa volutpat venenatis eleifend, tortor velit tincidunt metus, at molestie felis neque non est. Curabitur lorem est, ullamcorper quis pellentesque et, consequat a tortor. Duis at lorem et erat pretium ultrices. Sed fringilla neque nec ante interdum ultricies. In facilisis augue eget nisi porttitor in semper risus vulputate. Suspendisse id mi velit. Pellentesque in libero ac neque ullamcorper vulputate interdum pharetra ligula. Pellentesque ac diam justo. Maecenas augue est, tincidunt vel lobortis in, condimentum nec felis. Morbi sodales luctus velit, in fringilla augue consectetur sed. Pellentesque ut sodales augue. Etiam et sem lacus. Nullam at erat lectus, lobortis vulputate augue. Curabitur nec risus blandit libero ornare posuere quis ac mi. Quisque sed odio tellus, eu vehicula dolor. Aenean luctus pellentesque rhoncus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam eget augue quis ligula adipiscing molestie. Suspendisse ac dictum lorem. Vivamus lacus diam, tincidunt ut sagittis non, consectetur ut magna. Maecenas lectus lectus, suscipit vitae commodo nec, mollis id nibh. Curabitur venenatis posuere ipsum, nec tincidunt tortor pulvinar vel. Vestibulum metus tortor, gravida eu lacinia ut, mattis sed ante. In eu justo id arcu consectetur molestie. Praesent mattis scelerisque mauris, ac porttitor velit malesuada quis. Etiam elementum sem a eros aliquam venenatis eget in tortor. Pellentesque a risus libero. Donec erat diam, porta id blandit vel, vulputate ac diam."
TextWrapping="Wrap" />
</Grid>
</ScrollViewer>
</Grid>