-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Setting Background Property doesnt cover all space for MenuItem in ContextMenu #18071
Comments
It seems that when using |
@nickodei I think it is a bug, i cant somehow bypass this behavior |
I think you shouldn't place a MenuItem in DataTemplate. Instead use ItemContainerTheme to edit Background or other properties. |
@timunie I cant understand how to use ItemContainerTheme for MenuItem. When i try to use ControlTheme with data from view model, ItemContainerTheme for MenuItem is null Code below :
|
Something closer to this:
<ContextMenu ItemsSource="{Binding MacrosContextMenu}">
<ContextMenu.ItemContainerTheme>
<ControlTheme TargetType="MenuItem" BasedOn="{StaticResource {x:Type MenuItem}}"
x:DataType="vm:MacrosItem">
<Setter Property="Background" Value="{Binding BackgroundColor}"/>
<Setter Property="Foreground" Value="{Binding HeaderTextColor}"/>
<Setter Property="CommandParameter" Value="{Binding ElementName=editor, Path=SelectedText}"/>
</ControlTheme>
</ContextMenu.ItemContainerTheme>
<ContextMenu.ItemTemplate>
<DataTemplate x:DataType="vm:MacrosItem">
<TextBlock Content="{Binding Header}" />
</DataTemplate>
</ContextMenu.ItemTemplate>
</ContextMenu> |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Describe the bug
Setting Background Property doesnt cover all space for MenuItem in ContextMenu
I`am trying to set colors for MenuItems but i got this (color dont fill all space)
To Reproduce
Code
View:
ViewModel:
private ObservableCollection _MacrosContextMenu = new ObservableCollection() { new MacrosItem() { Header="test", HeaderTextColor=Brushes.Green,BackgroundColor=Brushes.Honeydew } };
public ObservableCollection MacrosContextMenu {
get => _MacrosContextMenu;
set => this.RaiseAndSetIfChanged(ref _MacrosContextMenu, value);
}
Full project code: https://github.com/SwiftExtender/JsonTable
Expected behavior
Background Color will fill all space
Avalonia version
11.2.3
OS
Windows
Additional context
No response
The text was updated successfully, but these errors were encountered: