C# 如何在xaml中将超链接添加到堆栈面板
我使用c#从web服务绑定了值,我的xaml代码如下所示C# 如何在xaml中将超链接添加到堆栈面板,c#,xaml,windows-phone-8,windows-phone-8.1,C#,Xaml,Windows Phone 8,Windows Phone 8.1,我使用c#从web服务绑定了值,我的xaml代码如下所示 <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <StackPanel> <ListBox x:Name="PhoneList" Height="532" Background="{x:Null}"> <ListBox.ItemTemplate> <DataTemplate
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<StackPanel>
<ListBox x:Name="PhoneList" Height="532" Background="{x:Null}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Height="100" Margin="5" Stretch="Fill" Width="100" Source="{Binding blogImage}"></Image>
<Grid x:Name="ContentPanel" Margin="20,0,0,0" Width="300" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock TextWrapping="Wrap" LineHeight=" 24" MaxHeight=" 48"LineStackingStrategy="BlockLineHeight" Grid.Row="0" Foreground="Black" FontStyle="Normal" Text="{Binding blogTitle }" Margin="0,0,0,0"/>
<TextBlock Grid.Row="2" VerticalAlignment="Top" TextWrapping="Wrap" Margin="0,3,0,0" Foreground="BlueViolet" FontStyle="Italic" Text="{Binding blogPostedon }" />
</Grid>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</Grid>
如何将超链接添加到整个堆栈面板,并且我的超链接值位于数据绑定中
<HyperLinkButton>
<HyperLinkButton.Content>
<StackPanel>
...
</StackPanel>
</HyperLinkButton.Content>
</HyperLinkButton>
...
仅支持文本
<HyperlinkButton>
Hello World
</HyperlinkButton>
你好,世界
但是您可以这样做,设置一个控件模板并在其中输入上面提到的XAML
<HyperlinkButton>
<HyperlinkButton.Template>
<ControlTemplate x:Key="MyTemplate" TargetType="Button">
<StackPanel>
<ListBox x:Name="PhoneList" Height="532" Background="{x:Null}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
.....
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
</ControlTemplate>
</HyperlinkButton.Template>
</HyperlinkButton>
.....
是否要为StackPanel或TextBlock添加?您的问题标题为TextBlock将所需的StackPanel或TextBlock包装在“HyperlinkButton.Content”中@sanjeetharan:抱歉,我只需要编辑堆栈面板…@位标记在环绕堆栈面板时不被接受请在我的回答中查看exmaple添加所有列表值后隐藏X:键不被接受available@user2992174好,检查修改后的答案