Wpf 如何在文本框中添加超链接和文本
这是我的密码:Wpf 如何在文本框中添加超链接和文本,wpf,hyperlink,textbox,textblock,Wpf,Hyperlink,Textbox,Textblock,这是我的密码: <TextBlock TextWrapping="Wrap" TextAlignment="Left"> <TextBox IsReadOnly="True" BorderThickness="0" TextWrapping="Wrap"> Please enter your details for login: questions follow the link </TextBox> <Hyper
<TextBlock TextWrapping="Wrap" TextAlignment="Left">
<TextBox IsReadOnly="True" BorderThickness="0" TextWrapping="Wrap">
Please enter your details for login: questions follow the link
</TextBox>
<Hyperlink NavigateUri="https:" RequestNavigate="Hyperlink_RequestNavigate">
Reset Password
</Hyperlink>
</TextBlock>
请输入您的登录详细信息:问题请点击链接
重置密码
文本框不允许我在文本中设置超链接。我需要将超链接保留在文本框之外,这样会创建一个新行。但是我想要超链接到文本
我之所以在文本块内使用文本框,是为了使文本可选择。如果您将外部
文本块
替换为堆叠面板
,它是否实现了您想要的效果
<StackPanel Orientation="Horizontal">
<TextBox VerticalAlignment="Center" IsReadOnly="True" BorderThickness="0" TextWrapping="Wrap">
Please enter your details for login: questions follow the link
</TextBox>
<TextBlock VerticalAlignment="Center">
<Hyperlink NavigateUri="https:" RequestNavigate="Hyperlink_RequestNavigate">
Reset Password
</Hyperlink>
</TextBlock>
</StackPanel>
请输入您的登录详细信息:问题请点击链接
重置密码
如果您将外部文本块
替换为堆叠面板
,它是否达到了您想要的效果
<StackPanel Orientation="Horizontal">
<TextBox VerticalAlignment="Center" IsReadOnly="True" BorderThickness="0" TextWrapping="Wrap">
Please enter your details for login: questions follow the link
</TextBox>
<TextBlock VerticalAlignment="Center">
<Hyperlink NavigateUri="https:" RequestNavigate="Hyperlink_RequestNavigate">
Reset Password
</Hyperlink>
</TextBlock>
</StackPanel>
请输入您的登录详细信息:问题请点击链接
重置密码
我建议使用单个RichTextBox
解决方案:
<RichTextBox IsReadOnly="True" IsDocumentEnabled="True" >
<FlowDocument>
<Paragraph>
Please enter your details for login: questions follow the link
<Hyperlink NavigateUri="https:" RequestNavigate="Hyperlink_RequestNavigate">Reset Password</Hyperlink>
</Paragraph>
</FlowDocument>
</RichTextBox>
请输入您的登录详细信息:问题请点击链接
重置密码
我建议使用单个RichTextBox
解决方案:
<RichTextBox IsReadOnly="True" IsDocumentEnabled="True" >
<FlowDocument>
<Paragraph>
Please enter your details for login: questions follow the link
<Hyperlink NavigateUri="https:" RequestNavigate="Hyperlink_RequestNavigate">Reset Password</Hyperlink>
</Paragraph>
</FlowDocument>
</RichTextBox>
请输入您的登录详细信息:问题请点击链接
重置密码
由于上面的堆栈面板将元素水平对齐,因此无法达到要求。我的窗口大小有问题,所以文本和超链接应该进入新行。@user1118468然后设置StackPanel Orientation=“Vertical”它没有达到要求,因为上面的堆栈面板水平对齐元素。我的窗口大小有问题,所以文本和超链接应该进入新行。@user1118468然后设置StackPanel方向=“垂直”