Fix styles as Styles (not ResourceDictionary); replace DataTriggers with width converters; add IsZeroConverter; remove unsupported properties; fix ancestor command bindings; bind SplitView props directly.
This commit is contained in:
parent
c624127bf9
commit
1667fc8b3d
9 changed files with 146 additions and 101 deletions
|
@ -11,34 +11,16 @@
|
|||
<UserControl.Resources>
|
||||
<conv:BoolToGridLengthConverter x:Key="BoolToGridLengthConverter" />
|
||||
<conv:WidthToBooleanConverter x:Key="WidthToBooleanConverter" />
|
||||
<conv:IsZeroConverter x:Key="IsZeroConverter" />
|
||||
<conv:WidthToSplitViewModeConverter x:Key="WidthToSplitViewModeConverter" />
|
||||
<conv:WidthToPaneOpenConverter x:Key="WidthToPaneOpenConverter" />
|
||||
</UserControl.Resources>
|
||||
<!-- Replace columns with a responsive SplitView -->
|
||||
<SplitView x:Name="RootSplit"
|
||||
OpenPaneLength="320"
|
||||
CompactPaneLength="0">
|
||||
<!-- Responsive behavior: set DisplayMode and IsPaneOpen based on width -->
|
||||
<SplitView.Styles>
|
||||
<Style Selector="SplitView#RootSplit">
|
||||
<Style.Triggers>
|
||||
<!-- Narrow: Overlay mode, pane closed by default -->
|
||||
<DataTrigger Value="True"
|
||||
Binding="{Binding $parent[Window].Bounds.Width,
|
||||
Converter={StaticResource WidthToBooleanConverter},
|
||||
ConverterParameter=640}">
|
||||
<Setter Property="DisplayMode" Value="Overlay" />
|
||||
<Setter Property="IsPaneOpen" Value="False" />
|
||||
</DataTrigger>
|
||||
<!-- Wide: Inline mode, pane open -->
|
||||
<DataTrigger Value="False"
|
||||
Binding="{Binding $parent[Window].Bounds.Width,
|
||||
Converter={StaticResource WidthToBooleanConverter},
|
||||
ConverterParameter=640}">
|
||||
<Setter Property="DisplayMode" Value="Inline" />
|
||||
<Setter Property="IsPaneOpen" Value="True" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</SplitView.Styles>
|
||||
CompactPaneLength="0"
|
||||
DisplayMode="{Binding $parent[Window].Bounds.Width, Converter={StaticResource WidthToSplitViewModeConverter}, ConverterParameter=640}"
|
||||
IsPaneOpen="{Binding $parent[Window].Bounds.Width, Converter={StaticResource WidthToPaneOpenConverter}, ConverterParameter=640}">
|
||||
|
||||
<!-- Left pane: Variables + Functions -->
|
||||
<SplitView.Pane>
|
||||
|
@ -50,11 +32,11 @@
|
|||
|
||||
<!-- Variables list with empty-state hint overlay -->
|
||||
<Grid Grid.Row="0">
|
||||
<ListBox ItemsSource="{Binding Variables}" SelectedIndex="-1" HorizontalContentAlignment="Stretch"
|
||||
<ListBox ItemsSource="{Binding Variables}" SelectedIndex="-1"
|
||||
AutomationProperties.Name="Variables list">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="m:VariableItem">
|
||||
<Button Command="{Binding DataContext.InsertVariableCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
||||
<Button Command="{Binding $parent[UserControl].DataContext.InsertVariableCommand}"
|
||||
CommandParameter="{Binding VariableName}"
|
||||
Background="Transparent" BorderThickness="0" Padding="8" MinHeight="44"
|
||||
AutomationProperties.Name="Insert variable">
|
||||
|
@ -72,29 +54,19 @@
|
|||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<TextBlock Text="No variables yet. Define with: x = 5"
|
||||
IsVisible="False"
|
||||
IsVisible="{Binding Variables.Count, Converter={StaticResource IsZeroConverter}}"
|
||||
IsHitTestVisible="False"
|
||||
Opacity="0.6"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock.Styles>
|
||||
<Style Selector="TextBlock">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Variables.Count}" Value="0">
|
||||
<Setter Property="IsVisible" Value="True" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Styles>
|
||||
</TextBlock>
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
|
||||
<!-- Function definitions -->
|
||||
<ListBox Grid.Row="1" BorderThickness="0" HorizontalContentAlignment="Stretch"
|
||||
<ListBox Grid.Row="1" BorderThickness="0"
|
||||
ItemsSource="{x:Static m:FunctionDefinitionItem.DefinedFunctions}"
|
||||
AutomationProperties.Name="Functions list">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="m:FunctionDefinitionItem">
|
||||
<Button Command="{Binding DataContext.InsertFunctionCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
||||
<Button Command="{Binding $parent[UserControl].DataContext.InsertFunctionCommand}"
|
||||
CommandParameter="{Binding FunctionName}"
|
||||
Background="Transparent" BorderThickness="0" Padding="8" MinHeight="44"
|
||||
AutomationProperties.Name="Insert function">
|
||||
|
@ -143,24 +115,14 @@
|
|||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<TextBlock Text="No history yet. Enter an expression and Evaluate."
|
||||
IsVisible="False"
|
||||
IsVisible="{Binding History.Count, Converter={StaticResource IsZeroConverter}}"
|
||||
IsHitTestVisible="False"
|
||||
Opacity="0.6"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock.Styles>
|
||||
<Style Selector="TextBlock">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding History.Count}" Value="0">
|
||||
<Setter Property="IsVisible" Value="True" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Styles>
|
||||
</TextBlock>
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
|
||||
<!-- Input Row -->
|
||||
<Grid Grid.Row="1" ColumnDefinitions="Auto,Auto,*,Auto" Margin="4" ColumnSpacing="6">
|
||||
<Grid Grid.Row="1" ColumnDefinitions="Auto,Auto,*,Auto" Margin="4">
|
||||
<!-- Pane toggle: visible on narrow only -->
|
||||
<ToggleButton Margin="0,0,6,0"
|
||||
IsVisible="{Binding $parent[Window].Bounds.Width,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue