Click here to Skip to main content
14,693,599 members
Home » Discussions » Silverlight / WPF
   

Silverlight / WPF

 
QuestionMouseEventArgs.CLicks in WPF Pin
Enobong Adahada20-Apr-18 7:33
MemberEnobong Adahada20-Apr-18 7:33 
AnswerRe: MouseEventArgs.CLicks in WPF Pin
Gerry Schmitz20-Apr-18 14:18
mveGerry Schmitz20-Apr-18 14:18 
GeneralRe: MouseEventArgs.CLicks in WPF Pin
Enobong Adahada21-Apr-18 14:08
MemberEnobong Adahada21-Apr-18 14:08 
QuestionField Level Rights Pin
Kevin Marois18-Apr-18 8:38
professionalKevin Marois18-Apr-18 8:38 
AnswerRe: Field Level Rights Pin
Gerry Schmitz18-Apr-18 8:45
mveGerry Schmitz18-Apr-18 8:45 
GeneralRe: Field Level Rights Pin
Kevin Marois18-Apr-18 9:14
professionalKevin Marois18-Apr-18 9:14 
GeneralRe: Field Level Rights Pin
Gerry Schmitz18-Apr-18 9:43
mveGerry Schmitz18-Apr-18 9:43 
GeneralRe: Field Level Rights Pin
Kevin Marois18-Apr-18 9:54
professionalKevin Marois18-Apr-18 9:54 
Maybe you're not understanding what I'm trying to accomplish here.

When a user logs in their rights are retrieved and stored on a static class in a Dictionary. See below
public static class AppCore
{
    // List of user's rights
    public static Dictionary<string, bool> Rights { get; set; }

    // Logs the user in
    public static void Login(string userName, string password)
    {
        // Login the user. If successful....

        // ....get their rights. In my app the User Object 
        // has the dictionary of rights on it. The user
        // object is returned from the BL with the dictionary
        // on it. It looks like this
        /*
        CurtentUser.Rights<"CanAddCustomer", true>;
        CurtentUser.Rights<"CanEditCustomer", true >;
        CurtentUser.Rights<"CanDeleteCustomer", true >;
        CurtentUser.Rights<"CustomerCreditLimit", true >;
        */
        // So after login, I do
        CurrentUser.Rights.ForEach(x => Rights.Add(x));

        // At this point, the app is up & running and I have access to 
        // the user's right from anywhere
    }

    public static bool HasAccess(string itemName)
    {
        return Rights.Where(x => x.Key == itemName).Select(x => x.Value).FirstOrDefault();
    }
}
What I want to do now is call HasAccess from the XAML. All I should have to do is set the key ("CanEditCustomer" or "CustomerCreditLimit"), or maybe the element name, on the UI element.

I have this working already with simply binding to the dictionary and setting the key, as in my original posting... What I'd really like is instead of binding to a property, I want call a method on the VM so I can do advanced logic.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.


modified 18-Apr-18 15:01pm.

GeneralRe: Field Level Rights Pin
Gerry Schmitz18-Apr-18 10:50
mveGerry Schmitz18-Apr-18 10:50 
AnswerRe: Field Level Rights Pin
Mycroft Holmes18-Apr-18 15:31
professionalMycroft Holmes18-Apr-18 15:31 
QuestionApplication.Run C# equivalent Pin
GregJ717-Apr-18 5:32
MemberGregJ717-Apr-18 5:32 
AnswerRe: Application.Run C# equivalent Pin
Richard MacCutchan17-Apr-18 5:38
mveRichard MacCutchan17-Apr-18 5:38 
GeneralRe: Application.Run C# equivalent Pin
GregJ717-Apr-18 7:26
MemberGregJ717-Apr-18 7:26 
GeneralRe: Application.Run C# equivalent Pin
Richard MacCutchan17-Apr-18 7:38
mveRichard MacCutchan17-Apr-18 7:38 
GeneralRe: Application.Run C# equivalent Pin
GregJ717-Apr-18 8:59
MemberGregJ717-Apr-18 8:59 
GeneralRe: Application.Run C# equivalent Pin
Richard MacCutchan17-Apr-18 9:47
mveRichard MacCutchan17-Apr-18 9:47 
GeneralRe: Application.Run C# equivalent Pin
GregJ717-Apr-18 9:04
MemberGregJ717-Apr-18 9:04 
GeneralRe: Application.Run C# equivalent Pin
Richard MacCutchan17-Apr-18 9:48
mveRichard MacCutchan17-Apr-18 9:48 
GeneralRe: Application.Run C# equivalent Pin
Richard Deeming19-Apr-18 2:52
mveRichard Deeming19-Apr-18 2:52 
GeneralRe: Application.Run C# equivalent Pin
GregJ719-Apr-18 3:42
MemberGregJ719-Apr-18 3:42 
AnswerRe: Application.Run C# equivalent Pin
GregJ717-Apr-18 12:52
MemberGregJ717-Apr-18 12:52 
GeneralRe: Application.Run C# equivalent Pin
Richard MacCutchan17-Apr-18 21:53
mveRichard MacCutchan17-Apr-18 21:53 
GeneralRe: Application.Run C# equivalent Pin
GregJ718-Apr-18 2:24
MemberGregJ718-Apr-18 2:24 
GeneralRe: Application.Run C# equivalent Pin
Richard MacCutchan18-Apr-18 2:37
mveRichard MacCutchan18-Apr-18 2:37 
AnswerRe: Application.Run C# equivalent Pin
Pete O'Hanlon18-Apr-18 2:52
subeditorPete O'Hanlon18-Apr-18 2:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.