CurrencyEntryBox use psuedoclass and different template for readonly mode.
MODIFY
WalletWasabi.Fluent/Controls/CurrencyEntryBox.axaml
WalletWasabi.Fluent/Controls/CurrencyEntryBox.axaml
Margin="{DynamicResource TextBoxTopHeaderMargin}" />
<DataValidationErrors DockPanel.Dock="Bottom" Margin="0 10 0 0" />
-
- <Panel>
- <Panel IsVisible="{TemplateBinding IsReadOnly}">
- <Border
- BorderThickness="{TemplateBinding BorderThickness}"
- MinWidth="{TemplateBinding MinWidth}"
- MinHeight="{TemplateBinding MinHeight}" />
- <Panel
- Margin="{TemplateBinding BorderThickness}">
- <Panel
- Margin="{TemplateBinding Padding}">
- <DockPanel>
- <StackPanel Orientation="Horizontal">
- <TextBlock Text="{TemplateBinding Text}"
- TextAlignment="{TemplateBinding TextAlignment}"
- TextWrapping="{TemplateBinding TextWrapping}"
- HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
- VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
- <TextBlock Margin="5 0 0 0"
- Text="{TemplateBinding CurrencyCode}"
- IsVisible="{TemplateBinding Text, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
- HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
- VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
- <TextBlock DockPanel.Dock="Right"
- Margin="20 0 0 0"
- Opacity="0.5"
- Text="{TemplateBinding ConversionText}"
- HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
- VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
- </StackPanel>
-
- <Panel>
-
- <!-- TODO eliminate this margin... text layout issue? -->
-
- </Panel>
- </DockPanel>
- </Panel>
- </Panel>
- </Panel>
<Panel IsVisible="{Binding !$parent[c:CurrencyEntryBox].IsReadOnly}">
<Border
Name="PART_BorderElement"
<PathIcon Data="{StaticResource arrow_swap}" Width="16" />
</Button>
</Panel>
+ </DockPanel>
+ </ControlTemplate>
+ </Setter>
+ </Style>
+
+ <Style Selector="c|CurrencyEntryBox:readonly">
+ <Setter Property="Template">
+ <ControlTemplate>
+ <DockPanel>
+ <ContentPresenter x:Name="PART_HeaderContentPresenter"
+ DockPanel.Dock="Top"
+ TextBlock.FontWeight="Normal"
+ TextBlock.Foreground="{DynamicResource TextControlHeaderForeground}"
+ IsVisible="False"
+ Margin="{DynamicResource TextBoxTopHeaderMargin}" />
+
+ <DataValidationErrors DockPanel.Dock="Bottom" Margin="0 10 0 0" />
+
+ <Panel>
+ <Border
+ BorderThickness="{TemplateBinding BorderThickness}"
+ MinWidth="{TemplateBinding MinWidth}"
+ MinHeight="{TemplateBinding MinHeight}" />
+ <Panel
+ Margin="{TemplateBinding BorderThickness}">
+ <Panel
+ Margin="{TemplateBinding Padding}">
+ <DockPanel>
+ <StackPanel Orientation="Horizontal">
+ <TextBlock Text="{TemplateBinding Text}"
+ TextAlignment="{TemplateBinding TextAlignment}"
+ TextWrapping="{TemplateBinding TextWrapping}"
+ HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+ VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
+ <TextBlock Margin="5 0 0 0"
+ Text="{TemplateBinding CurrencyCode}"
+ IsVisible="{TemplateBinding Text, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
+ HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+ VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
+ <TextBlock DockPanel.Dock="Right"
+ Margin="20 0 0 0"
+ Opacity="0.5"
+ Text="{TemplateBinding ConversionText}"
+ HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
+ VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
+ </StackPanel>
+ </DockPanel>
+ </Panel>
+ </Panel>
</Panel>
</DockPanel>
</ControlTemplate>

MODIFY
WalletWasabi.Fluent/Controls/CurrencyEntryBox.axaml.cs
WalletWasabi.Fluent/Controls/CurrencyEntryBox.axaml.cs
@@ -386,5 +386,15 @@ namespace WalletWasabi.Fluent.Controls
}
}
}
+
+ protected override void OnPropertyChanged<T>(AvaloniaPropertyChangedEventArgs<T> change)
+ {
+ base.OnPropertyChanged(change);
+
+ if (change.Property == IsReadOnlyProperty)
+ {
+ PseudoClasses.Set(":readonly", change.NewValue.GetValueOrDefault<bool>());
+ }
+ }
}
}
\ No newline at end of file

CurrencyEntryBox use psuedoclass and different template for readonly mode.