Problems when I compile GraphSharp.Controls from souce code

Aug 2, 2011 at 12:38 PM
Edited Aug 3, 2011 at 9:53 AM

Hello,

in my app I added an event handler to the vertex control to catch the 'MouseLeftButtonDown' event.

 

<ControlTemplate TargetType="{x:Type graphsharp:VertexControl}">
                        <Border BorderBrush="LightGray"
                            BorderThickness="0"
                            CornerRadius="1,1,1,1"
                            MouseLeftButtonDown="Element_MouseLeftButtonDown"

 

...

I the code behind I cast the sender to PocVertex and retrieve an IPaddress to launch a browser.

 

private void Element_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            string address = ((DashBoard.PocVertex)(((System.Windows.FrameworkElement)(sender)).DataContext)).IPAddress;
           
            if (e.ClickCount > 1)
            {
                // View Browser...
                DashboardBrowserPage dashBoardBrowserPage = new DashboardBrowserPage(address);
                this.NavigationService.Navigate(dashBoardBrowserPage);
            }
        }

 

This all works as long I use the GraphSharp.Controls.dll which was provided in the GraphSharp-v1.0-release package. When I now use the souce code add that project to my project, compile it and run it  the content of the sender changes. It returns a an object named like my viewmodel and can't be casted to PocVertex. So I get an exception. 

Also the data binding to <TextBlock Text="{Binding ID}"/> of the graphsharp:EdgeControl is not longer working.

<ToolTip x:Key="ToolTipContent">
                    <StackPanel>
                        <TextBlock FontWeight="Bold" Text="Edge Information"/>
                        <TextBlock Text="{Binding ID}"/>
                    </StackPanel>
                </ToolTip>

 

Does anyone have an idea of the reason for that behaviour? Maight it have something to do with different target framworkes of the two projects? I there something to migrate when I cange it to .NET4.0?

 

Thx NBT0511

 

Here is some additional information which I gathered from the sender: For me it looks as it losts the connection to

graphsharp. 

 

OK orgiginal GraphSharp.Controls.dll:


DataContext: 192.168.0.202
0011FC04DA20


SenderName: Border
BaseType: System.Windows.Controls.Decorator
GUID: 90ddcb80-e12f-3a37-8f12-fb5cfb791af3
QualifiedName: System.Windows.Controls.Border, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
FullName: System.Windows.Controls.Border
Namespace: System.Windows.Controls
UnderlyingSystemType: System.Windows.Controls.Border


new compiled GraphSharp.Controls.dll:

DataContext: DashBoard.DshBrdHomePageViewModel

SenderName: Border
BaseType: System.Windows.Controls.Decorator
GUID: 90ddcb80-e12f-3a37-8f12-fb5cfb791af3
QualifiedName: System.Windows.Controls.Border, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
FullName: System.Windows.Controls.Border
Namespace: System.Windows.Controls
UnderlyingSystemType: System.Windows.Controls.Border

 

 

Sep 15, 2011 at 3:22 PM

I want to come back to that Binding problem in the edges tooltip:

..."Also the data binding to <TextBlock Text="{Binding ID}"/> of the graphsharp:EdgeControl is not longer working."

 

<Style TargetType="{x:Type graphsharp:EdgeControl}">
            <Style.Resources>
                <ToolTip x:Key="ToolTipContent">
                    <StackPanel>
                                                      
                         <TextBlock FontWeight="Bold" Text="Edge Information"/>

                         <TextBlock Text="{Binding ID}"/>

                    </StackPanel>
                </ToolTip>
            </Style.Resources>
            <Setter Property="ToolTip" Value="{StaticResource ToolTipContent}"/>
        </Style>

 

I doublechecked that problem with the GraphSharpDemo of sachabarber.net. Also there is the same problem.

What I found for the time being is that the DataItem for the resp. Edge-Style changes from DataItem=’PocEdge’ [OK] to DataItem=’MainWindowViewModel’ [faulty].

Any idea why would be appreciated.