如何在xaml中添加超链接到堆栈面板
本文关键字:堆栈 超链接 添加 xaml | 更新日期: 2023-09-27 18:05:12
我已经使用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>
<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
只支持Text。
<HyperlinkButton>
Hello World
</HyperlinkButton>
但是你可以这样做,设置一个Control模板,并在
中输入上面提到的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>