質問
どのように私は、WPFのハイパーリンクの箇条書きリストをデータ・バインドを作成するのですか?
私はこれを持ってます:
<ItemsControl Name="lstScripts">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock>
<Hyperlink>
<TextBlock Text="{Binding Path=Name}" />
</Hyperlink>
</TextBlock>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
しかし、私は弾丸にアイテムを有効にする方法を見つけ出すことはできません。私は、標準的な弾丸をしたい、私はBulletDecoratorを参照してください、私は私自身の弾丸の画像を指定する必要はありません。
解決
残念ながら「標準弾丸」は存在しない...ここでは、単純な楕円の弾丸の一例です。
<ItemsControl Name="lstScripts">
<ItemsControl.ItemTemplate>
<DataTemplate>
<BulletDecorator Width="Auto">
<BulletDecorator.Bullet>
<Ellipse Fill="White" Stroke="Black" StrokeThickness="1" Width="8" Height="8"/>
</BulletDecorator.Bullet>
<TextBlock>
<Hyperlink>
<TextBlock Text="{Binding Path=Name}" />
</Hyperlink>
</TextBlock>
</BulletDecorator>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
他のヒント
ちょうどあなたが、それを再利用することができますので、ユーザーコントロールにそれを作る、@Thomasレベスクの答えビットを拡張する例えば:ます。
<Reporting:BulletedItem BulletText="Bullet Item 1" />
<Reporting:BulletedItem BulletText="Bullet Item 2" />
ユーザーコントロールを作成します:
<UserControl x:Class="MyNameSpace.Reporting.BulletedItem"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" >
<Grid>
<ItemsControl >
<BulletDecorator Width="Auto" Margin="10, 0, 0, 0">
<BulletDecorator.Bullet>
<Ellipse Fill="Black" Stroke="Black" StrokeThickness="1" Width="5" Height="5"/>
</BulletDecorator.Bullet>
<TextBlock Margin="5, 0, 0, 0">
<TextBlock Text="{Binding BulletText}" />
</TextBlock>
</BulletDecorator>
</ItemsControl>
</Grid>
</UserControl>
コードで
public partial class BulletedItem : UserControl
{
public static readonly DependencyProperty TextProperty = DependencyProperty.Register("BulletText", typeof(string), typeof(BulletedItem));
public string BulletText
{
get { return (string)GetValue(TextProperty); }
set { SetValue(TextProperty, value); }
}
public BulletedItem()
{
InitializeComponent();
this.DataContext = this;
}
}
リストのすべての種類のためには、FlowDocumentやリストを使用することができます。これは、「ディスク」との1のMarkerStyleている「サークル。」
<FlowDocument>
<List MarkerStyle="Disc">
<ListItem>
<Paragraph>Boron</Paragraph>
</ListItem>
<ListItem>
<Paragraph>Carbon</Paragraph>
</ListItem>
</<FlowDocument>
詳細はこちらあります: https://msdn.microsoft .COM /ライブラリ/ aa970909(V = VS.100).aspxのの
所属していません StackOverflow