You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm building a customizable toolbar like MS Word Toolbar. My concept is a lot of XAML and less code. It actually worked. Some controls like MenuFlyout, which I have known for a long time, always have issues.
The type of the property "Items" is IEnumerable of TrayItem. It works and contains two items. (See image below)
But the binding is wrong. I looked with a debugger and found the issue. The DataContext of each item is MainWindowsViewModel instead TrayItem. Why is it there? Actually it's not true!!
I only used the test converter for debugging and removed "EffectiveLabel" to look at it. <Setter Property="Header" Value="{Binding Converter={StaticResource TestConverter}}"/>
Unfortunately, the {Binding} does not work in ItemContainerTheme! DataContext of each MenuItem is wrong. The value TrayItem should be set in DataContext. It that correct?
Describe the bug
I'm building a customizable toolbar like MS Word Toolbar. My concept is a lot of XAML and less code. It actually worked. Some controls like MenuFlyout, which I have known for a long time, always have issues.
The type of the property "Items" is
IEnumerable
ofTrayItem
. It works and contains two items. (See image below)But the binding is wrong. I looked with a debugger and found the issue. The DataContext of each item is
MainWindowsViewModel
insteadTrayItem
. Why is it there? Actually it's not true!!<MenuFlyout ItemsSource="{Binding Items, RelativeSource={...
I could solve the problem with just code, but I really want XAML. Unfortunately it doesn't work.
See screenhot:

I only used the test converter for debugging and removed "EffectiveLabel" to look at it.
<Setter Property="Header" Value="{Binding Converter={StaticResource TestConverter}}"/>
It doesn't work with "RelativeSource" either.
It doesn't work with "RelativeSource" either.
However, when I add
$self
, the result showsMenuItem
with the wrong DataContextMainWindowsViewModel
. The DataContext should actually beTrayItem
.To Reproduce
I'm building my own toolbar. The name
Tray
is unrelated to SystemTray or ToolbarTray.1 Create a customizable toolbar
2 Add many items (
TrayItem
)3 Add two underlying items in a item (
TrayItem
)This item,
TrayItem
, automatically contains aDropDownButton
because it holds two items and does not have a command source.VisualTree shows this structure
Expected behavior
No response
Avalonia version
11.2.1
OS
Windows
Additional context
No response
The text was updated successfully, but these errors were encountered: