Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open WpfDataUI up to glue theming #181

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions WpfDataUi/Controls/CheckBoxDisplay.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void Refresh(bool forceRefreshEvenIfFocused = false)
HintTextBlock.Visibility = !string.IsNullOrEmpty(InstanceMember?.DetailText) ? Visibility.Visible : Visibility.Collapsed;
HintTextBlock.Text = InstanceMember?.DetailText;

CheckBox.Foreground = DesiredForegroundBrush;
SetForeground(DesiredForegroundBrush);

RefreshIsEnabled();

Expand Down Expand Up @@ -166,11 +166,19 @@ private void CheckBoxChanged(object sender, RoutedEventArgs e)
{
this.TrySetValueOnInstance();

SetForeground(DesiredForegroundBrush);
}
}

CheckBox.Foreground = DesiredForegroundBrush;



private void SetForeground(Brush brush)
{
if (brush == Brushes.Black)
{
CheckBox.ClearValue(Control.ForegroundProperty);
}
else
{
CheckBox.Foreground = brush;
}
}

Expand Down
11 changes: 9 additions & 2 deletions WpfDataUi/Controls/TextBoxDisplayLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ public static object TryHandleMathOperation(string usableString, Type instancePr
}
}

public static SolidColorBrush DefaultValueBackground = new SolidColorBrush(System.Windows.Media.Color.FromRgb(180, 255, 180));
public static SolidColorBrush DefaultValueBackground = new SolidColorBrush(System.Windows.Media.Color.FromRgb(180, 255, 180)) { Opacity = 0.5 };
public static SolidColorBrush IndeterminateValueBackground = new SolidColorBrush(System.Windows.Media.Colors.LightGray);
public static SolidColorBrush CustomValueBackground = System.Windows.Media.Brushes.White;

Expand Down Expand Up @@ -491,7 +491,14 @@ public void RefreshDisplay()
}
else
{
mAssociatedTextBox.Background = CustomValueBackground;
if (mAssociatedTextBox.TryFindResource("Frb.Brushes.TextBox.Background") != null)
{
mAssociatedTextBox.SetResourceReference(TextBox.BackgroundProperty, "Frb.Brushes.TextBox.Background");
}
else
{
mAssociatedTextBox.ClearValue(TextBox.BackgroundProperty);
}
}
}
}
Expand Down
17 changes: 15 additions & 2 deletions WpfDataUi/DataUiGrid.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,25 @@
Margin="1"
local:DataGridAttachedProperties.HideExpanderArrow="{Binding HideHeader}"
>
<ItemsControl x:Name="ItemsControlInstance" ItemsSource="{Binding Members}" Focusable="False">
<ItemsControl x:Name="ItemsControlInstance" ItemsSource="{Binding Members}" Focusable="False" AlternationCount="2">
<ItemsControl.Resources>
<SolidColorBrush x:Key="LightBg" Color="White" Opacity="0.1"/>
<SolidColorBrush x:Key="DarkBg" Color="Black" Opacity="0.05"/>
</ItemsControl.Resources>
<ItemsControl.ItemTemplate>
<DataTemplate>
<DataUi:SingleDataUiContainer FontSize="12" Margin="3,0,3,3" Background="{Binding BackgroundColor}"/>
<DataUi:SingleDataUiContainer x:Name="Container" FontSize="12" Margin="3,0,3,0" Padding="0,2"/>
<DataTemplate.Triggers>
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter TargetName="Container" Property="Background" Value="{StaticResource LightBg}"/>
</Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter TargetName="Container" Property="Background" Value="{StaticResource DarkBg}"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>

</ItemsControl>
</Expander>
</DataTemplate>
Expand Down