在我的MainWindow
中,我必须使用附加属性执行TitleBar
隐藏或在ViewModel中可见。我不知道如何做到这一点。请任何人都可以给我一个建议或任何解决方法来实现这一目标。我是.Net的新手
public static readonly DependencyProperty TitleBarProperty = DependencyProperty.Register("TitleBarVisible", typeof(bool), typeof(Syncfusion.Windows.Tools.Controls.TitleBar));
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(String propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
public bool TitleBarVisible
{
get { return (bool)GetValue(MainWindow.TitleBarProperty); }
set
{
SetValue(MainWindow.TitleBarProperty, value);
OnPropertyChanged("TitleBarVisible");
}
}
答案 0 :(得分:0)
我没有像这样使用附加的peroperty来实现这个目标,
<强> MainWindow.xaml.cs 强>
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
MainWindow window = sender as MainWindow;
window.TitleBar.Visibility = Visibility.Collapsed;
}
<强> MainViewModel 强>
public void HideTitleBar(object obj)
{
(App.Current.MainWindow as MainWindow).TitleBar.Visibility = Visibility.Visible;
}