farzad
farzad

Reputation: 7

How to set IsOpen property of Fluent.Ribbon StartScreen from ViewModel in WPF?

I'm working on a WPF application using the Fluent.Ribbon library, and I'm facing an issue with setting the IsOpen property of the StartScreen control from my view model. I have a MainViewModel that is set as the DataContext of my MainWindow, and I want to be able to control the visibility of the StartScreen from the view model. Here's how my XAML looks:

<Fluent:Ribbon Grid.Row="0" FlowDirection="RightToLeft">
    <!-- Start Screen -->
    <Fluent:Ribbon.StartScreen IsOpen="{Binding IsStartScreenOpen}" />
    <!-- Other ribbon content -->
</Fluent:Ribbon>

And here's the relevant property in my MainViewModel:

public class MainViewModel : INotifyPropertyChanged
{
    private bool _isStartScreenOpen;

    public bool IsStartScreenOpen
    {
        get { return _isStartScreenOpen; }
        set
        {
            if (_isStartScreenOpen != value)
            {
                _isStartScreenOpen = value;
                OnPropertyChanged(nameof(IsStartScreenOpen));
            }
        }
    }

    
}

However, setting the IsStartScreenOpen property in my view model doesn't seem to update the visibility of the StartScreen control.

What am I missing? How can I properly set the IsOpen property of the StartScreen from my view model?

Any help or suggestions would be greatly appreciated. Thank you!

Upvotes: 0

Views: 62

Answers (1)

mm8
mm8

Reputation: 169410

Your XAML markup is invalid and won't compile.

You should bind the property on the actual StartScreen element, e.g.:

<Fluent:Ribbon Grid.Row="0" FlowDirection="RightToLeft">
    <Fluent:Ribbon.StartScreen>
        <Fluent:StartScreen IsOpen="{Binding IsStartScreenOpen}">
            ...
        </Fluent:StartScreen>
    </Fluent:Ribbon.StartScreen>
</Fluent:Ribbon>

Upvotes: 0

Related Questions