मैं एक RichTextBlock तत्व में एक हाइपरलिंक दिखाने में सक्षम होना चाहता हूं, लेकिन मैं यह भी सही दिखना चाहता हूं। निकटतम मैं यह है करने के लिए प्राप्त करने में सक्षम किया गया है:मैं RichTextBlock में हाइपरलिंक कैसे बना सकता हूं पूरी तरह से असाइन नहीं किया जा सकता है?
इस के लिए XAML नीचे चिपकाया जाता है - अनिवार्य रूप से, मैं InlineUIElement
का उपयोग करें और मैं संसाधन संपादित बटन भर के सभी crud दूर करने के लिए। क्या मैं कुछ भूल रहा हूँ? क्या इसका हल करने का एकमात्र असली तरीका है अपना खुद का हाइपरलिंक रोल करना?
यहाँ रिच टेक्स्ट ब्लॉक के लिए XAML है:
<RichTextBlock VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="14">
<Paragraph>I just want this
<InlineUIContainer>
<HyperlinkButton Style="{StaticResource HyperlinkButtonStyle1}">Hyperlink</HyperlinkButton>
</InlineUIContainer>
to not look like crap
</Paragraph>
</RichTextBlock>
और यहाँ nuked संसाधन के लिए XAML है:
<Style x:Key="HyperlinkButtonStyle1" TargetType="HyperlinkButton">
<Setter Property="Foreground" Value="{StaticResource HyperlinkForegroundThemeBrush}"/>
<Setter Property="Background" Value="{StaticResource HyperlinkButtonBackgroundThemeBrush}"/>
<!--<Setter Property="BorderBrush" Value="{StaticResource HyperlinkButtonBorderThemeBrush}"/>-->
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="FontFamily" Value="Global User Interface"/>
<Setter Property="FontSize" Value="14"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="HyperlinkButton">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="PointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource HyperlinkPointerOverForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource HyperlinkPressedForegroundThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource HyperlinkDisabledThemeBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="FocusStates">
<VisualState x:Name="Focused">
<Storyboard>
<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisualWhite"/>
<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="FocusVisualBlack"/>
</Storyboard>
</VisualState>
<VisualState x:Name="Unfocused"/>
<VisualState x:Name="PointerFocused"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" VerticalAlignment="Bottom">
<ContentPresenter x:Name="ContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTransitions="{TemplateBinding ContentTransitions}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="0" VerticalAlignment="Bottom"/>
</Border>
<Rectangle x:Name="FocusVisualWhite" IsHitTestVisible="False" Opacity="0" StrokeDashOffset="1.5" StrokeEndLineCap="Square" Stroke="{StaticResource FocusVisualWhiteStrokeThemeBrush}" StrokeDashArray="1,1"/>
<Rectangle x:Name="FocusVisualBlack" IsHitTestVisible="False" Opacity="0" StrokeDashOffset="0.5" StrokeEndLineCap="Square" Stroke="{StaticResource FocusVisualBlackStrokeThemeBrush}" StrokeDashArray="1,1"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
हाँ - टेक्स्टबटन स्टाइल का उपयोग करके एक ही सटीक प्रभाव देता है ... –
@ShaharPrish मेरा संपादन देखें। – mydogisbox
धन्यवाद को प्रभावित करने के लिए आपको बस टेम्पलेट को थोड़ा सा ट्विक करने की आवश्यकता है। ऐसा लगता है कि यह बेहतर काम करता है - अभी भी अच्छा नहीं लग रहा है, लेकिन कम से कम यह गठबंधन है। इसे "बस काम किया" की इच्छा है। –