尝试从usercontrol获取属性

This commit is contained in:
liufei
2021-07-09 17:31:44 +08:00
parent ccd00afbb2
commit a6b7a2e816
4 changed files with 59 additions and 12 deletions

View File

@@ -8,7 +8,7 @@
mc:Ignorable="d"
>
<WrapPanel HorizontalAlignment="Center" VerticalAlignment="Top">
<ListBox x:Name="IconfontList" ItemsSource="{Binding}" BorderThickness="0" Background="AliceBlue">
<ListBox x:Name="IconListBox" ItemsSource="{Binding iconListSystem}" SelectionChanged="ListBox_SelectionChanged" BorderThickness="0" Background="AliceBlue">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Horizontal" Background="Transparent"/>

View File

@@ -1,4 +1,5 @@
using System;
using GeekDesk.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -25,5 +26,37 @@ namespace GeekDesk.Control.UserControls.IconFont
InitializeComponent();
}
public static readonly DependencyProperty IconfontListProperty = DependencyProperty.Register("IconfontList", typeof(List<IconfontInfo>), typeof(IconPannel));
public List<IconfontInfo> IconfontList
{
get
{
return (List<IconfontInfo>)GetValue(IconfontListProperty);
}
set
{
SetValue(IconfontListProperty, true);
}
}
public static readonly DependencyProperty IconInfoProperty = DependencyProperty.Register("IconInfo", typeof(IconfontInfo), typeof(IconPannel));
public IconfontInfo IconInfo
{
get
{
return (IconfontInfo)GetValue(IconInfoProperty);
}
set
{
SetValue(IconInfoProperty, true);
}
}
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
IconfontInfo info = IconfontList[IconListBox.SelectedIndex];
IconInfo = info;
}
}
}