- region Path
FrameworkElementFactory pathSelectedFactory =new FrameworkElementFactory(typeof(Path), “pathSelected”); - region Inner StackPanel
FrameworkElementFactory spInnerFactory =new FrameworkElementFactory(typeof(StackPanel));
spInnerFactory.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal); - region DataTrigger
DataTrigger dataTrigger = new DataTrigger();
dataTrigger.Binding = new Binding {
Path = new PropertyPath(ListBoxItem.IsSelectedProperty),
RelativeSource =
new RelativeSource(RelativeSourceMode.FindAncestor,
typeof(ListBoxItem), 1)
};
dataTrigger.Value = true;
dataTrigger.Setters.Add(
new Setter(FrameworkElement.VisibilityProperty,
Visibility.Visible, “pathSelected”));
前台示例: