Issue with dependency properties on Visual Studio "Properties" window
I am working on a custom WPF Window
and I am facing an issue with a DependencyProperty
.
Here is an example of my base class MyCustomWindow.cs
:
public class MyCustomWindow : Window
{
public static DependencyProperty UseTitleBarProperty = DependencyProperty.Register("UseTitleBar", typeof(bool), typeof(MyCustomWindow), new PropertyMetadata(true));
[Category("CUSTOM")]
[Description("...")]
public bool UseTitleBar
{
get { return (bool)GetValue(UseTitleBarProperty); }
set { SetValue(UseTitleBarProperty, value); }
}
}
An example of my extended class MainWindow.xaml.cs
:
public partial class MainWindow : MyCustomWindow
{
public MainWindow()
{
InitializeComponent();
}
}
And an example of my MainWindow.xaml
:
<mlc:MyCustomWindow x:Class="MyApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MyApp"
mc:Ignorable="d"
xmlns:mlc="clr-namespace:MyLib.Controls;assembly=MyLib"
Height="640"
Title="MainWindow"
Width="840"
WindowStartupLocation="CenterScreen"
UseTitleBar="False">
<Grid>
</Grid>
</mlc:MyCustomWindow>
Programmatically it "works". But I am facing an issue on "Properties" window of Visual Studio. When I try to change the value of UseTitleBar
property from there (properties window) it always displayed as true
and the value doesn't change inside the code.
Even if I change UseTitleBar
value from MainWindow.xaml
code, on Properties window displays as true
!!! Is this a VS issue or am I doing something wrong?
Thank you for your time!!!