Skip to content

Commit

Permalink
如果属性不支持则设置背景灰色
Browse files Browse the repository at this point in the history
  • Loading branch information
lindexi committed Jul 10, 2024
1 parent 176abed commit c500ad9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/dotnetCampus.UISpy.Uno/UnoSpyPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@

<Page.Resources>
<pe:EditorViewTemplateSelector x:Key="PropertyValueTemplateSelector" />
<local:ElementPropertyProxyToBackgroundConverter x:Key="ElementPropertyProxyToBackgroundConverter" />
</Page.Resources>

<Grid >
<Grid ColumnDefinitions="*,*,*">
<Grid RowDefinitions="Auto,*" >
<Grid Grid.Row="1" ColumnDefinitions="*,*,*">

<Border Grid.Column="0" BorderThickness="1" BorderBrush="#005A9E" HorizontalAlignment="Right" />
<Border Grid.Column="1" BorderThickness="1" BorderBrush="#005A9E" HorizontalAlignment="Right" />
Expand All @@ -37,7 +38,7 @@
<ListView x:Name="VisualTreeElementPropertyListView" Grid.Column="1" SelectionMode="None">
<ListView.ItemTemplate>
<DataTemplate x:DataType="tree:ElementPropertyProxy">
<Grid RowDefinitions="*,*" ColumnDefinitions="*,3*">
<Grid RowDefinitions="*,*" ColumnDefinitions="*,3*" Background="{Binding Converter={StaticResource ElementPropertyProxyToBackgroundConverter}}">
<Border Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left"
Height="16" CornerRadius="8" Margin="-4 0" Padding="4 0"
Background="#EAEAEAEA">
Expand Down
31 changes: 31 additions & 0 deletions src/dotnetCampus.UISpy.Uno/UnoSpyPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,34 @@ private static async ValueTask<ImageSource> RenderBitmap(UIElement element)
return rtb;
}
}



public class ElementPropertyProxyToBackgroundConverter : IValueConverter
{
public object? Convert(object value, Type targetType, object parameter, string language)
{
if (value is ElementPropertyProxy elementPropertyProxy)
{
var color = Colors.Transparent;

if (elementPropertyProxy.IsNotImplemented)
{
color = Colors.LightGray;
}
else if (elementPropertyProxy.IsFailed)
{
color = Colors.OrangeRed;
}

return new SolidColorBrush(color);
}

return null;
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotSupportedException();
}
}

0 comments on commit c500ad9

Please sign in to comment.