1

I created a class that inherits from Window and has got a DependencyProperty called TitlebarContent.

public FrameworkElement TitleBarContent { get { return (FrameworkElement)GetValue(TitleBarContentProperty); } set { SetValue(TitleBarContentProperty, value); } } // Using a DependencyProperty as the backing store for TitleBarContent. This enables animation, styling, binding, etc... public static readonly DependencyProperty TitleBarContentProperty = DependencyProperty.Register("TitleBarContent", typeof(FrameworkElement), typeof(tkWindowControl), new PropertyMetadata(default(FrameworkElement))); 

Inside a ResourceDictionary for Styles i add a ContentControlfor this property. Now I'd like to use the new 'WindowObject' in another application and access the new TitlebarContentProperty. I can see the items inside my Titlebar and I'm able to move the Window, resize it and more. But I cannot bind to these items. For example I'd like to add a Helpbutton inside the Titlebar. The Button is shown, but i can't click it.

 <tk:tkWindowControl.TitleBarContent> <DockPanel Grid.Row="0" FlowDirection="LeftToRight"> <Button Content="Exit" Command="{Binding ExitApplicationCommand}" Height="60" Width="60" Background="Red"/> </DockPanel> </tk:tkWindowControl.TitleBarContent> 

My DependencyProperty is a typeof(FrameWorkElement) because i like to add several Buttons to the Titlebar.

Is it possible to use my Bindings in this way?

2
  • If your button shows up in the UI then I would expect all you need to do is have a public iCommand property ExitApplicationCommand in the datacontext of your window. What do you have at the moment? Commented Apr 17, 2019 at 9:31
  • The Background is already done. I tried the Binding by placing the button in a normal Grid. Everything works. But used in the Titlebarcontent the Button has no IsMouseOverEffect and the Binding doesn't work anymore. Commented Apr 17, 2019 at 10:38

1 Answer 1

1

Set the WindowChrome.IsHitTestVisibleInChrome attached property of the Button or the parent element to true:

<Button Content="Exit" WindowChrome.IsHitTestVisibleInChrome="True" ... /> 

Alternatively, you should decrease the value of the CaptionHeight property of the WindowChrome.

Sign up to request clarification or add additional context in comments.

1 Comment

And again you helped me @mm8. Now i'm done with my UI. Thank you

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.