textblock

UWP Scale textblock inside treeview - text wrapping

心已入冬 提交于 2021-02-08 07:27:34
问题 Can please anyone help, I am working on a UWP app and I want TextBlock to wrap the text inside it according to window width. That Textblock is inside Grid which is inside TreeView. Now when I resize my app window it doesn't do anything. Original: Resized: I want it to look like this and don't have fixed width but to change dynamically with window: This is my XAML code: <TreeView Name="ItemsTreeView" SelectionMode="Multiple" ItemsSource="{x:Bind DataSource}" CanReorderItems="False" CanDrag=

UWP Scale textblock inside treeview - text wrapping

巧了我就是萌 提交于 2021-02-08 07:25:36
问题 Can please anyone help, I am working on a UWP app and I want TextBlock to wrap the text inside it according to window width. That Textblock is inside Grid which is inside TreeView. Now when I resize my app window it doesn't do anything. Original: Resized: I want it to look like this and don't have fixed width but to change dynamically with window: This is my XAML code: <TreeView Name="ItemsTreeView" SelectionMode="Multiple" ItemsSource="{x:Bind DataSource}" CanReorderItems="False" CanDrag=

Textblock in Viewbox not multiline

柔情痞子 提交于 2021-02-05 07:59:05
问题 I'm having a bit of a trouble with the autosizing of a text. I read somewhere that if I wanted to achieve that, i need to put my textblock in a viewbox . The problem with that is this way the text isn't split into multiple lines. For example "very very very long text" is almost unreadable, but "simpletext" looks just fine. <Viewbox Grid.Row="1" Grid.Column="0" Grid.RowSpan="2" Grid.ColumnSpan="4" StretchDirection="DownOnly"> <TextBlock Text="{Binding FieldName}" VerticalAlignment="Center"

write string to textblock on different page in C#, UWP

送分小仙女□ 提交于 2021-01-29 13:30:17
问题 How can I write into a TextBlock on a different page? So far it only works with TextBlocks on the same page. The async function is in Page_1 . The TextBlock is on Page_2 . public async void Serial() { string rxBuffer; //code //code //code while (true) { textblock_DebugRx_Gas_live.Text = rxBuffer; } } 回答1: write string to textblock on different page in C#, UWP If the two page display in foreground at same time like following. <Grid> <Grid.RowDefinitions> <RowDefinition Height="1*"/>

Format date with StringFormat in TextBlock in WPF

五迷三道 提交于 2021-01-29 06:30:47
问题 I have stored date in database without slashing for some reason . it means that I have a date field like 20110602. As i want to retrieve this date and show it in a textblock I need a formatting to show this date as a normal date with slash. How can i use StringFormat in this way ? ... does anyone konw what format should I use to convert "20110602" to 2011/06/02 ? <TextBlock Text="{Binding CreatedDate, StringFormat=?????" 回答1: If you perfer the route of implementing a converter: class

Format date with StringFormat in TextBlock in WPF

这一生的挚爱 提交于 2021-01-29 06:22:01
问题 I have stored date in database without slashing for some reason . it means that I have a date field like 20110602. As i want to retrieve this date and show it in a textblock I need a formatting to show this date as a normal date with slash. How can i use StringFormat in this way ? ... does anyone konw what format should I use to convert "20110602" to 2011/06/02 ? <TextBlock Text="{Binding CreatedDate, StringFormat=?????" 回答1: If you perfer the route of implementing a converter: class

not to set Hyperlink when NavigateUri is null

末鹿安然 提交于 2020-12-16 05:36:33
问题 I am using Hyperlink in TextBlock . The problem I am facing is when NavigateUri is null, I don't want to set Hyperlink or use default style, so that there is no difference between TextBlock and Hyperlink . How to do this? The code that I am using is this: <TextBlock TextWrapping="Wrap"> <Hyperlink NavigateUri="{Binding Path=Href}" RequestNavigate="Hyperlink_RequestNavigate"> <Run Text="{Binding Path=Body}"/> </Hyperlink> </TextBlock> Sometimes Href is null. That time I don't have to set

Binding Run inside Textblock results in exception in WPF

时间秒杀一切 提交于 2020-08-27 03:39:36
问题 I'm trying to bind two <Run> s inside a TextBlock as shown in the snippet below. But I'm getting an XamlParseException . Basically I'm trying to achieve this format: CodeNum: LongDescription If the below code is doomed to fail what other alternatives do I have? <TextBlock> <Run FontWeight="Bold" Text="{Binding CodeNum}"/> <Run FontWeight="Bold" Text=": "/> <Run Text="{Binding LongDescription}"/> </TextBlock> 回答1: I'm guessing that either LongDescription or CodeNumis is a read-only property