Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Contextmenu questions (Read 8813 times)
Waterfiets
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Sep 27th, 2013
Contextmenu questions
Dec 17th, 2013 at 2:01pm
Print Post  
Hi Stoyan,

In our application i'm using an Contextmenu to edit some node values. After a while i wanted to change the look of the contextmenu by changing the color so it would fit the design of our modeler. Well, it did change the color but not of the whole context menu. There seems to be some sort of 'strip' on the left side of the menu which seems to keep the original color.

What i want to do is either remove the part on the left, which seems reserved for icons, or change the color of the 'strip' so it doesn't interfere with the look.

Could you give any information on why this is happening and how i can fix it?

Thanks in advance.

Greets,

Sander
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Contextmenu questions
Reply #1 - Dec 17th, 2013 at 3:09pm
Print Post  
Hi,

It seems you'll have to modify menu's Xaml template to edit that color:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/23bc2e08-d220-4e21-bd08-4a...

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Waterfiets
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Sep 27th, 2013
Re: Contextmenu questions
Reply #2 - Dec 17th, 2013 at 3:11pm
Print Post  
Hi Stoyan,

Ah, you probably had better search criteria then i had. Thanks for the info, atleast i know its possible:)

Greets,

Sander
  
Back to top
 
IP Logged
 
Waterfiets
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Sep 27th, 2013
Re: Contextmenu questions
Reply #3 - Dec 19th, 2013 at 11:19am
Print Post  
Hi Stoyan,

Thanks to your suggestion i was able to make a template for my custom Contextmenu in a WPF based testproject and it worked out pretty nice. Now i wanted to apply this to the main project which is a wf project that hosts the Mindfusion wpf project.

The problem i encountered is that once i set the style of my MenuItem to Application.Current.Resources[MenuItemStyle] as Style; Which refers to my xaml in the code below. I get an error. Do you perhaps have any tips on how to solve this?

Code
Select All
 <Application x:Class="TSFBRModeler.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="BRModeler.xaml">
    <Application.Resources>
            <Style TargetType="{x:Type MenuItem}" x:Key="MenuItemStyle">
                <Setter Property="Background" Value="Gray"></Setter>
                <Setter Property="Foreground" Value="White"></Setter>
                <Setter Property="FontSize" Value="13"></Setter>
                <Setter Property="FontFamily" Value="Verdana"></Setter>
                <Setter Property="Margin" Value="-5,0,0,0"></Setter>
                <Style.Triggers>
                    <Trigger Property="IsHighlighted" Value="True">
                        <Setter Property="Background" Value="Black"></Setter>
                        <Setter Property="FontSize" Value="15"></Setter>
                    </Trigger>
                    <Trigger Property="IsEnabled" Value="False">
                        <Setter Property="Foreground" Value="LightGray"></Setter>
                    </Trigger>
                </Style.Triggers>
            </Style>
    </Application.Resources>
</Application> 




Greets,

Sander
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Contextmenu questions
Reply #4 - Dec 19th, 2013 at 1:57pm
Print Post  
What kind of error are you getting?
  
Back to top
 
IP Logged
 
Waterfiets
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Sep 27th, 2013
Re: Contextmenu questions
Reply #5 - Dec 20th, 2013 at 7:33am
Print Post  
Well i assume the problem is that WF doesnt have application wide resources, i.e. App.xaml. Which means i cant reach the file which contains the information about the template. Anyhows, i found a workaround, i made the template programmatically instead of using the xaml. Thanks anyway:D
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Contextmenu questions
Reply #6 - Dec 20th, 2013 at 8:01am
Print Post  
Well, it works without any errors in my test, with your exact Xaml copied to App.xaml:

Code
Select All
if (e.MouseButton == MouseButton.Right)
{
	var menu = new ContextMenu();
	var item = new MenuItem();
	item.Header = "that's me";
	item.Style = (System.Windows.Style)Application.Current.Resources["MenuItemStyle"];
	menu.Items.Add(item);
	menu.IsOpen = true;
	return;
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Waterfiets
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Sep 27th, 2013
Re: Contextmenu questions
Reply #7 - Jan 8th, 2014 at 10:30am
Print Post  
Hi,

This is the stacktrace of the error i get:

Code
Select All
   at TSFBRModeler.TSFBRDiagramNodes.TSFBRContextNodes.BRSetActiveTabNode.Draw(DrawingContext graphics, RenderOptions options) in c:\Users\sleune\trunk_bsr\TSFBRModeler\TSFBRDiagramNodes\TSFBRContextNodes\BRSetActiveTabNode.cs:line 353
   at MindFusion.Diagramming.Wpf.DiagramItem.OnRender(DrawingContext drawingContext)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at A.A.ArrangeOverride(Size arrangeSize)
   at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
   at System.Windows.UIElement.Arrange(Rect finalRect)
   at System.Windows.ContextLayoutManager.UpdateLayout()
   at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
   at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget) 



Maybe you see something i dont. Cool

Edit:

Line 353 = rightField.Style = (System.Windows.Style)Application.Current.Resources["MenuItemStyle"];

Edit:

Extra info: The TSFBRModeler WPF solution is hosted by the WF Solution TSFBRModelerBootStrap. And the startup type of TSFBRModeler is class library.

Would the startupuri then be different?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Contextmenu questions
Reply #8 - Jan 8th, 2014 at 12:26pm
Print Post  
What kind of exception is thrown there?
  
Back to top
 
IP Logged
 
Waterfiets
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Sep 27th, 2013
Re: Contextmenu questions
Reply #9 - Jan 8th, 2014 at 1:11pm
Print Post  
It threw an Null Reference exception, i.e. the value of the object was null.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Contextmenu questions
Reply #10 - Jan 8th, 2014 at 1:36pm
Print Post  
And it isn't the rightField variable having a null value?
  
Back to top
 
IP Logged
 
Waterfiets
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Sep 27th, 2013
Re: Contextmenu questions
Reply #11 - Jan 8th, 2014 at 2:56pm
Print Post  
Nope, the values are hard coded atm.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Contextmenu questions
Reply #12 - Jan 8th, 2014 at 3:16pm
Print Post  
If you add a breakpoint to that Line 353, which one is null when it hits - rightField, Application.Current or Application.Current.Resources?
  
Back to top
 
IP Logged
 
Waterfiets
Junior Member
**
Offline


I Love MindFusion!

Posts: 78
Joined: Sep 27th, 2013
Re: Contextmenu questions
Reply #13 - Jan 8th, 2014 at 3:18pm
Print Post  
The value of Application.Current is null.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Contextmenu questions
Reply #14 - Jan 8th, 2014 at 3:25pm
Print Post  
Code
Select All
static App()
{
	Debug.WriteLine(Application.Current);
}

App()
{
	Debug.WriteLine(Application.Current);
} 



This test shows Application.Current is null during static initialization, and is already set in the instance constructor App() (i.e. once the base Application constructor has executed). So I suppose your code runs from a static constructor or initializer of some kind, and apparently you won't be able to access resources then. You should still be able to load the style at a later point.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint