Search Results

Search found 7152 results on 287 pages for 'silverlight toolkit'.

Page 9/287 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Scope of the Pages in a Silverlight application

    - by AngryHacker
    I have an app built with the Silverlight Navigation Application Template. I have a main form (e.g. MainPage.xaml) and a bunch of Silverlight Pages, which are swapped in and out of the main content area. In the MainPage.xaml, I have a DispatcherTimer which hits some Uri resources, regardless of which page I am on. Every now and then, it will inexplicably stop firing. I have an inkling that it has to do with the scope of various pages. Can pages inside the MainPage.xaml take away the scope from its parent? Or is this something much simpler?

    Read the article

  • Should i use a trigger or Behaviors for this?

    - by Michael
    I have an abstract object called Applicant and two different types of objects that inherit from Applicant called Business and Individual. So I have three classes that look like this: public abstract class Applicant { ... } public class Individual : Applicant { ... } public class Business : Applicant { ... } Now in the DataGrid I want to show all the details of Applicant object. When you choose a row I want to show details of either the business or individual as a internal grid. Something like this <DataGrid> <DataGrid.Columns> <!--Show different columns --> </DataGrid.Columns> <DataGrid.RowDetailsTemplate> <!--Show if Individual --> <DataGrid> <DataGrid.Columns> <DataGridTextColumn Header="First Name" ... /> <DataGridTextColumn Header="Last Name" ... /> </DataGrid.Columns> </DataGrid> <!--Show if business --> <DataGrid> <DataGrid.Columns> <DataGridTextColumn Header="Business Name" ... /> <DataGridTextColumn Header="Tax id" ... /> </DataGrid.Columns> </DataGrid> </DataGrid.RowDetailsTemplate> </DataGrid> Now I'm not sure if I need to use a Triggers or Behaviors to accomplish this? Thanks for everyones help! FYI I'm using Silverlight 4.0 with Prism.

    Read the article

  • Creating Custom Ajax Control Toolkit Controls

    - by Stephen Walther
    The goal of this blog entry is to explain how you can extend the Ajax Control Toolkit with custom Ajax Control Toolkit controls. I describe how you can create the two halves of an Ajax Control Toolkit control: the server-side control extender and the client-side control behavior. Finally, I explain how you can use the new Ajax Control Toolkit control in a Web Forms page. At the end of this blog entry, there is a link to download a Visual Studio 2010 solution which contains the code for two Ajax Control Toolkit controls: SampleExtender and PopupHelpExtender. The SampleExtender contains the minimum skeleton for creating a new Ajax Control Toolkit control. You can use the SampleExtender as a starting point for your custom Ajax Control Toolkit controls. The PopupHelpExtender control is a super simple custom Ajax Control Toolkit control. This control extender displays a help message when you start typing into a TextBox control. The animated GIF below demonstrates what happens when you click into a TextBox which has been extended with the PopupHelp extender. Here’s a sample of a Web Forms page which uses the control: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ShowPopupHelp.aspx.cs" Inherits="MyACTControls.Web.Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html > <head runat="server"> <title>Show Popup Help</title> </head> <body> <form id="form1" runat="server"> <div> <act:ToolkitScriptManager ID="tsm" runat="server" /> <%-- Social Security Number --%> <asp:Label ID="lblSSN" Text="SSN:" AssociatedControlID="txtSSN" runat="server" /> <asp:TextBox ID="txtSSN" runat="server" /> <act:PopupHelpExtender id="ph1" TargetControlID="txtSSN" HelpText="Please enter your social security number." runat="server" /> <%-- Social Security Number --%> <asp:Label ID="lblPhone" Text="Phone Number:" AssociatedControlID="txtPhone" runat="server" /> <asp:TextBox ID="txtPhone" runat="server" /> <act:PopupHelpExtender id="ph2" TargetControlID="txtPhone" HelpText="Please enter your phone number." runat="server" /> </div> </form> </body> </html> In the page above, the PopupHelp extender is used to extend the functionality of the two TextBox controls. When focus is given to a TextBox control, the popup help message is displayed. An Ajax Control Toolkit control extender consists of two parts: a server-side control extender and a client-side behavior. For example, the PopupHelp extender consists of a server-side PopupHelpExtender control (PopupHelpExtender.cs) and a client-side PopupHelp behavior JavaScript script (PopupHelpBehavior.js). Over the course of this blog entry, I describe how you can create both the server-side extender and the client-side behavior. Writing the Server-Side Code Creating a Control Extender You create a control extender by creating a class that inherits from the abstract ExtenderControlBase class. For example, the PopupHelpExtender control is declared like this: public class PopupHelpExtender: ExtenderControlBase { } The ExtenderControlBase class is part of the Ajax Control Toolkit. This base class contains all of the common server properties and methods of every Ajax Control Toolkit extender control. The ExtenderControlBase class inherits from the ExtenderControl class. The ExtenderControl class is a standard class in the ASP.NET framework located in the System.Web.UI namespace. This class is responsible for generating a client-side behavior. The class generates a call to the Microsoft Ajax Library $create() method which looks like this: <script type="text/javascript"> $create(MyACTControls.PopupHelpBehavior, {"HelpText":"Please enter your social security number.","id":"ph1"}, null, null, $get("txtSSN")); }); </script> The JavaScript $create() method is part of the Microsoft Ajax Library. The reference for this method can be found here: http://msdn.microsoft.com/en-us/library/bb397487.aspx This method accepts the following parameters: type – The type of client behavior to create. The $create() method above creates a client PopupHelpBehavior. Properties – Enables you to pass initial values for the properties of the client behavior. For example, the initial value of the HelpText property. This is how server property values are passed to the client. Events – Enables you to pass client-side event handlers to the client behavior. References – Enables you to pass references to other client components. Element – The DOM element associated with the client behavior. This will be the DOM element associated with the control being extended such as the txtSSN TextBox. The $create() method is generated for you automatically. You just need to focus on writing the server-side control extender class. Specifying the Target Control All Ajax Control Toolkit extenders inherit a TargetControlID property from the ExtenderControlBase class. This property, the TargetControlID property, points at the control that the extender control extends. For example, the Ajax Control Toolkit TextBoxWatermark control extends a TextBox, the ConfirmButton control extends a Button, and the Calendar control extends a TextBox. You must indicate the type of control which your extender is extending. You indicate the type of control by adding a [TargetControlType] attribute to your control. For example, the PopupHelp extender is declared like this: [TargetControlType(typeof(TextBox))] public class PopupHelpExtender: ExtenderControlBase { } The PopupHelp extender can be used to extend a TextBox control. If you try to use the PopupHelp extender with another type of control then an exception is thrown. If you want to create an extender control which can be used with any type of ASP.NET control (Button, DataView, TextBox or whatever) then use the following attribute: [TargetControlType(typeof(Control))] Decorating Properties with Attributes If you decorate a server-side property with the [ExtenderControlProperty] attribute then the value of the property gets passed to the control’s client-side behavior. The value of the property gets passed to the client through the $create() method discussed above. The PopupHelp control contains the following HelpText property: [ExtenderControlProperty] [RequiredProperty] public string HelpText { get { return GetPropertyValue("HelpText", "Help Text"); } set { SetPropertyValue("HelpText", value); } } The HelpText property determines the help text which pops up when you start typing into a TextBox control. Because the HelpText property is decorated with the [ExtenderControlProperty] attribute, any value assigned to this property on the server is passed to the client automatically. For example, if you declare the PopupHelp extender in a Web Form page like this: <asp:TextBox ID="txtSSN" runat="server" /> <act:PopupHelpExtender id="ph1" TargetControlID="txtSSN" HelpText="Please enter your social security number." runat="server" />   Then the PopupHelpExtender renders the call to the the following Microsoft Ajax Library $create() method: $create(MyACTControls.PopupHelpBehavior, {"HelpText":"Please enter your social security number.","id":"ph1"}, null, null, $get("txtSSN")); You can see this call to the JavaScript $create() method by selecting View Source in your browser. This call to the $create() method calls a method named set_HelpText() automatically and passes the value “Please enter your social security number”. There are several attributes which you can use to decorate server-side properties including: ExtenderControlProperty – When a property is marked with this attribute, the value of the property is passed to the client automatically. ExtenderControlEvent – When a property is marked with this attribute, the property represents a client event handler. Required – When a value is not assigned to this property on the server, an error is displayed. DefaultValue – The default value of the property passed to the client. ClientPropertyName – The name of the corresponding property in the JavaScript behavior. For example, the server-side property is named ID (uppercase) and the client-side property is named id (lower-case). IDReferenceProperty – Applied to properties which refer to the IDs of other controls. URLProperty – Calls ResolveClientURL() to convert from a server-side URL to a URL which can be used on the client. ElementReference – Returns a reference to a DOM element by performing a client $get(). The WebResource, ClientResource, and the RequiredScript Attributes The PopupHelp extender uses three embedded resources named PopupHelpBehavior.js, PopupHelpBehavior.debug.js, and PopupHelpBehavior.css. The first two files are JavaScript files and the final file is a Cascading Style sheet file. These files are compiled as embedded resources. You don’t need to mark them as embedded resources in your Visual Studio solution because they get added to the assembly when the assembly is compiled by a build task. You can see that these files get embedded into the MyACTControls assembly by using Red Gate’s .NET Reflector tool: In order to use these files with the PopupHelp extender, you need to work with both the WebResource and the ClientScriptResource attributes. The PopupHelp extender includes the following three WebResource attributes. [assembly: WebResource("PopupHelp.PopupHelpBehavior.js", "text/javascript")] [assembly: WebResource("PopupHelp.PopupHelpBehavior.debug.js", "text/javascript")] [assembly: WebResource("PopupHelp.PopupHelpBehavior.css", "text/css", PerformSubstitution = true)] These WebResource attributes expose the embedded resource from the assembly so that they can be accessed by using the ScriptResource.axd or WebResource.axd handlers. The first parameter passed to the WebResource attribute is the name of the embedded resource and the second parameter is the content type of the embedded resource. The PopupHelp extender also includes the following ClientScriptResource and ClientCssResource attributes: [ClientScriptResource("MyACTControls.PopupHelpBehavior", "PopupHelp.PopupHelpBehavior.js")] [ClientCssResource("PopupHelp.PopupHelpBehavior.css")] Including these attributes causes the PopupHelp extender to request these resources when you add the PopupHelp extender to a page. If you open View Source in a browser which uses the PopupHelp extender then you will see the following link for the Cascading Style Sheet file: <link href="/WebResource.axd?d=0uONMsWXUuEDG-pbJHAC1kuKiIMteQFkYLmZdkgv7X54TObqYoqVzU4mxvaa4zpn5H9ch0RDwRYKwtO8zM5mKgO6C4WbrbkWWidKR07LD1d4n4i_uNB1mHEvXdZu2Ae5mDdVNDV53znnBojzCzwvSw2&amp;t=634417392021676003" type="text/css" rel="stylesheet" /> You also will see the following script include for the JavaScript file: <script src="/ScriptResource.axd?d=pIS7xcGaqvNLFBvExMBQSp_0xR3mpDfS0QVmmyu1aqDUjF06TrW1jVDyXNDMtBHxpRggLYDvgFTWOsrszflZEDqAcQCg-hDXjun7ON0Ol7EXPQIdOe1GLMceIDv3OeX658-tTq2LGdwXhC1-dE7_6g2&amp;t=ffffffff88a33b59" type="text/javascript"></script> The JavaScrpt file returned by this request to ScriptResource.axd contains the combined scripts for any and all Ajax Control Toolkit controls in a page. By default, the Ajax Control Toolkit combines all of the JavaScript files required by a page into a single JavaScript file. Combining files in this way really speeds up how quickly all of the JavaScript files get delivered from the web server to the browser. So, by default, there will be only one ScriptResource.axd include for all of the JavaScript files required by a page. If you want to disable Script Combining, and create separate links, then disable Script Combining like this: <act:ToolkitScriptManager ID="tsm" runat="server" CombineScripts="false" /> There is one more important attribute used by Ajax Control Toolkit extenders. The PopupHelp behavior uses the following two RequirdScript attributes to load the JavaScript files which are required by the PopupHelp behavior: [RequiredScript(typeof(CommonToolkitScripts), 0)] [RequiredScript(typeof(PopupExtender), 1)] The first parameter of the RequiredScript attribute represents either the string name of a JavaScript file or the type of an Ajax Control Toolkit control. The second parameter represents the order in which the JavaScript files are loaded (This second parameter is needed because .NET attributes are intrinsically unordered). In this case, the RequiredScript attribute will load the JavaScript files associated with the CommonToolkitScripts type and the JavaScript files associated with the PopupExtender in that order. The PopupHelp behavior depends on these JavaScript files. Writing the Client-Side Code The PopupHelp extender uses a client-side behavior written with the Microsoft Ajax Library. Here is the complete code for the client-side behavior: (function () { // The unique name of the script registered with the // client script loader var scriptName = "PopupHelpBehavior"; function execute() { Type.registerNamespace('MyACTControls'); MyACTControls.PopupHelpBehavior = function (element) { /// <summary> /// A behavior which displays popup help for a textbox /// </summmary> /// <param name="element" type="Sys.UI.DomElement">The element to attach to</param> MyACTControls.PopupHelpBehavior.initializeBase(this, [element]); this._textbox = Sys.Extended.UI.TextBoxWrapper.get_Wrapper(element); this._cssClass = "ajax__popupHelp"; this._popupBehavior = null; this._popupPosition = Sys.Extended.UI.PositioningMode.BottomLeft; this._popupDiv = null; this._helpText = "Help Text"; this._element$delegates = { focus: Function.createDelegate(this, this._element_onfocus), blur: Function.createDelegate(this, this._element_onblur) }; } MyACTControls.PopupHelpBehavior.prototype = { initialize: function () { MyACTControls.PopupHelpBehavior.callBaseMethod(this, 'initialize'); // Add event handlers for focus and blur var element = this.get_element(); $addHandlers(element, this._element$delegates); }, _ensurePopup: function () { if (!this._popupDiv) { var element = this.get_element(); var id = this.get_id(); this._popupDiv = $common.createElementFromTemplate({ nodeName: "div", properties: { id: id + "_popupDiv" }, cssClasses: ["ajax__popupHelp"] }, element.parentNode); this._popupBehavior = new $create(Sys.Extended.UI.PopupBehavior, { parentElement: element }, {}, {}, this._popupDiv); this._popupBehavior.set_positioningMode(this._popupPosition); } }, get_HelpText: function () { return this._helpText; }, set_HelpText: function (value) { if (this._HelpText != value) { this._helpText = value; this._ensurePopup(); this._popupDiv.innerHTML = value; this.raisePropertyChanged("Text") } }, _element_onfocus: function (e) { this.show(); }, _element_onblur: function (e) { this.hide(); }, show: function () { this._popupBehavior.show(); }, hide: function () { if (this._popupBehavior) { this._popupBehavior.hide(); } }, dispose: function() { var element = this.get_element(); $clearHandlers(element); if (this._popupBehavior) { this._popupBehavior.dispose(); this._popupBehavior = null; } } }; MyACTControls.PopupHelpBehavior.registerClass('MyACTControls.PopupHelpBehavior', Sys.Extended.UI.BehaviorBase); Sys.registerComponent(MyACTControls.PopupHelpBehavior, { name: "popupHelp" }); } // execute if (window.Sys && Sys.loader) { Sys.loader.registerScript(scriptName, ["ExtendedBase", "ExtendedCommon"], execute); } else { execute(); } })();   In the following sections, we’ll discuss how this client-side behavior works. Wrapping the Behavior for the Script Loader The behavior is wrapped with the following script: (function () { // The unique name of the script registered with the // client script loader var scriptName = "PopupHelpBehavior"; function execute() { // Behavior Content } // execute if (window.Sys && Sys.loader) { Sys.loader.registerScript(scriptName, ["ExtendedBase", "ExtendedCommon"], execute); } else { execute(); } })(); This code is required by the Microsoft Ajax Library Script Loader. You need this code if you plan to use a behavior directly from client-side code and you want to use the Script Loader. If you plan to only use your code in the context of the Ajax Control Toolkit then you can leave out this code. Registering a JavaScript Namespace The PopupHelp behavior is declared within a namespace named MyACTControls. In the code above, this namespace is created with the following registerNamespace() method: Type.registerNamespace('MyACTControls'); JavaScript does not have any built-in way of creating namespaces to prevent naming conflicts. The Microsoft Ajax Library extends JavaScript with support for namespaces. You can learn more about the registerNamespace() method here: http://msdn.microsoft.com/en-us/library/bb397723.aspx Creating the Behavior The actual Popup behavior is created with the following code. MyACTControls.PopupHelpBehavior = function (element) { /// <summary> /// A behavior which displays popup help for a textbox /// </summmary> /// <param name="element" type="Sys.UI.DomElement">The element to attach to</param> MyACTControls.PopupHelpBehavior.initializeBase(this, [element]); this._textbox = Sys.Extended.UI.TextBoxWrapper.get_Wrapper(element); this._cssClass = "ajax__popupHelp"; this._popupBehavior = null; this._popupPosition = Sys.Extended.UI.PositioningMode.BottomLeft; this._popupDiv = null; this._helpText = "Help Text"; this._element$delegates = { focus: Function.createDelegate(this, this._element_onfocus), blur: Function.createDelegate(this, this._element_onblur) }; } MyACTControls.PopupHelpBehavior.prototype = { initialize: function () { MyACTControls.PopupHelpBehavior.callBaseMethod(this, 'initialize'); // Add event handlers for focus and blur var element = this.get_element(); $addHandlers(element, this._element$delegates); }, _ensurePopup: function () { if (!this._popupDiv) { var element = this.get_element(); var id = this.get_id(); this._popupDiv = $common.createElementFromTemplate({ nodeName: "div", properties: { id: id + "_popupDiv" }, cssClasses: ["ajax__popupHelp"] }, element.parentNode); this._popupBehavior = new $create(Sys.Extended.UI.PopupBehavior, { parentElement: element }, {}, {}, this._popupDiv); this._popupBehavior.set_positioningMode(this._popupPosition); } }, get_HelpText: function () { return this._helpText; }, set_HelpText: function (value) { if (this._HelpText != value) { this._helpText = value; this._ensurePopup(); this._popupDiv.innerHTML = value; this.raisePropertyChanged("Text") } }, _element_onfocus: function (e) { this.show(); }, _element_onblur: function (e) { this.hide(); }, show: function () { this._popupBehavior.show(); }, hide: function () { if (this._popupBehavior) { this._popupBehavior.hide(); } }, dispose: function() { var element = this.get_element(); $clearHandlers(element); if (this._popupBehavior) { this._popupBehavior.dispose(); this._popupBehavior = null; } } }; The code above has two parts. The first part of the code is used to define the constructor function for the PopupHelp behavior. This is a factory method which returns an instance of a PopupHelp behavior: MyACTControls.PopupHelpBehavior = function (element) { } The second part of the code modified the prototype for the PopupHelp behavior: MyACTControls.PopupHelpBehavior.prototype = { } Any code which is particular to a single instance of the PopupHelp behavior should be placed in the constructor function. For example, the default value of the _helpText field is assigned in the constructor function: this._helpText = "Help Text"; Any code which is shared among all instances of the PopupHelp behavior should be added to the PopupHelp behavior’s prototype. For example, the public HelpText property is added to the prototype: get_HelpText: function () { return this._helpText; }, set_HelpText: function (value) { if (this._HelpText != value) { this._helpText = value; this._ensurePopup(); this._popupDiv.innerHTML = value; this.raisePropertyChanged("Text") } }, Registering a JavaScript Class After you create the PopupHelp behavior, you must register the behavior as a class by using the Microsoft Ajax registerClass() method like this: MyACTControls.PopupHelpBehavior.registerClass('MyACTControls.PopupHelpBehavior', Sys.Extended.UI.BehaviorBase); This call to registerClass() registers PopupHelp behavior as a class which derives from the base Sys.Extended.UI.BehaviorBase class. Like the ExtenderControlBase class on the server side, the BehaviorBase class on the client side contains method used by every behavior. The documentation for the BehaviorBase class can be found here: http://msdn.microsoft.com/en-us/library/bb311020.aspx The most important methods and properties of the BehaviorBase class are the following: dispose() – Use this method to clean up all resources used by your behavior. In the case of the PopupHelp behavior, the dispose() method is used to remote the event handlers created by the behavior and disposed the Popup behavior. get_element() -- Use this property to get the DOM element associated with the behavior. In other words, the DOM element which the behavior extends. get_id() – Use this property to the ID of the current behavior. initialize() – Use this method to initialize the behavior. This method is called after all of the properties are set by the $create() method. Creating Debug and Release Scripts You might have noticed that the PopupHelp behavior uses two scripts named PopupHelpBehavior.js and PopupHelpBehavior.debug.js. However, you never create these two scripts. Instead, you only create a single script named PopupHelpBehavior.pre.js. The pre in PopupHelpBehavior.pre.js stands for preprocessor. When you build the Ajax Control Toolkit (or the sample Visual Studio Solution at the end of this blog entry), a build task named JSBuild generates the PopupHelpBehavior.js release script and PopupHelpBehavior.debug.js debug script automatically. The JSBuild preprocessor supports the following directives: #IF #ELSE #ENDIF #INCLUDE #LOCALIZE #DEFINE #UNDEFINE The preprocessor directives are used to mark code which should only appear in the debug version of the script. The directives are used extensively in the Microsoft Ajax Library. For example, the Microsoft Ajax Library Array.contains() method is created like this: $type.contains = function Array$contains(array, item) { //#if DEBUG var e = Function._validateParams(arguments, [ {name: "array", type: Array, elementMayBeNull: true}, {name: "item", mayBeNull: true} ]); if (e) throw e; //#endif return (indexOf(array, item) >= 0); } Notice that you add each of the preprocessor directives inside a JavaScript comment. The comment prevents Visual Studio from getting confused with its Intellisense. The release version, but not the debug version, of the PopupHelpBehavior script is also minified automatically by the Microsoft Ajax Minifier. The minifier is invoked by a build step in the project file. Conclusion The goal of this blog entry was to explain how you can create custom AJAX Control Toolkit controls. In the first part of this blog entry, you learned how to create the server-side portion of an Ajax Control Toolkit control. You learned how to derive a new control from the ExtenderControlBase class and decorate its properties with the necessary attributes. Next, in the second part of this blog entry, you learned how to create the client-side portion of an Ajax Control Toolkit control by creating a client-side behavior with JavaScript. You learned how to use the methods of the Microsoft Ajax Library to extend your client behavior from the BehaviorBase class. Download the Custom ACT Starter Solution

    Read the article

  • Silverlight As Transmedia Platform Silverlight TV

    I’m very excited to say that my discussion with John Papa about Silverlight as a Transmedia Storytelling Platform is live....Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Using initParams in Silverlight 4 project

    - by Silverlight Beginner
    I'm trying to upgrade a project that uses Silverlight 2 to use Silverlight 4 but I have problem with initparam to set domain. The old Silverlight 2 project: <form id="form1" runat="server" style="height:100%;"> <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <div style="height:100%;"> <asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/EKAKC.xap" MinimumVersion="2.0.31005.0" Width="100%" Height="100%" /> </div> </form> And from Default.aspx.cs: Xaml1.InitParameters += "Domain=" + domain; The new Silverlight 4 project: <body style="height: 100%; margin: 0;"> <form id="form1" runat="server" style="height: 100%;"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div id="silverlightControlHost"> <object type="application/x-silverlight-2" data="data:application/x-silverlight," width="300" height="300"> <param name="source" value="EKAKC.xap"/> <param name="initParams" value="<%= string.Format("WCFReferenceURL={0}", ConfigurationManager.AppSettings["WCFReferenceURL"])%>" /> </object> </div> The Domain will not be set in my new Silverlight 4 project

    Read the article

  • Trigger for ComboBox in Silverlight

    - by Budda
    Is there any possibility to display selected item of the ComboBox (after popup closing) in a way that is different from its displaying in DropDown List (There are players number and name in the dropdown list, but after list closing I want to see only its number). How can I change a background for the player with some Flag? As far as I know, all of that can be done with triggers, but are they supported in Silverlight 4, VS2010, Silverlight Toolkit 4? In my case the following code <ComboBox ItemsSource="{Binding PlayersAll}" SelectedItem="{Binding Path=SelectedPlayer, Mode=TwoWay}" > <ComboBox.ItemTemplate> <DataTemplate> <ToolkitControls:WrapPanel Orientation="Horizontal"> <TextBlock Text="{Binding TeamNumber}"/> <TextBlock Text=" - "/> <TextBlock Text="{Binding ShortName}"/> </ToolkitControls:WrapPanel> <DataTemplate.Triggers> <Trigger Property="HasError" Value="True"> <Setter Property="Background" TargetName="FlagSet" Value="Red"/> </Trigger> </DataTemplate.Triggers> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> gives an error: The property 'Triggers' does not exist on the type 'DataTemplate' in the XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation' what is wrong here? Here are my namespaces: xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data" xmlns:ToolkitControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"

    Read the article

  • Silverlight 4: How to find source UI element from contextmenu's menuitem_click?

    - by funwithcoding
    I have a datagrid and I added silverlight 4 toolkit contextmenu to textbox in datagrid as follows. When users right click on the textbox, contextmenu is being displayed. When users click the menu item with Header "Test", "MenuItem_Click" is getting executed. Now I want to access the textbox from the MenuItem_Click and modify its properties like background etc. Is there anyway to find textbox element(which is contextmenu's parent) from MenuItem_Click event? It appears to me that I am missing something very simple. <my:DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBox Text="{Binding AcctId}" Style="{StaticResource documentTextBoxStyle}" ToolTipService.ToolTip="Right Click to modify parameters" > <toolkit:ContextMenuService.ContextMenu > <toolkit:ContextMenu > <toolkit:MenuItem Header="Test" Click="MenuItem_Click"/> </toolkit:ContextMenu> </toolkit:ContextMenuService.ContextMenu> </TextBox> </DataTemplate>

    Read the article

  • using Silverlight 3's HtmlPage.Window.Navigate method to reuse an already open browser window

    - by Phil
    Hi, I want to use an external browser window to implement a preview functionality in a silverlight application. There is a list of items and whenever the user clicks one of these items, it's opened in a separate browser window (the content is a pdf document, which is why it is handled ouside of the SL app). Now, to achieve this, I simply use HtmlPage.Window.Navigate(new Uri("http://www.bing.com")); which works fine. Now my client doesn't like the fact that every click opens up a new browser window. He would like to see the browser window reused every time an item is clicked. So I went out and tried implementing this: Option 1 - Use the overload of the Navigate method, like so: HtmlPage.Window.Navigate(new Uri("http://www.bing.com"), "foo"); I was assuming that the window would be reused when the same target parameter value (foo) would be used in subsequent calls. This does not work. I get a new window every time. Option 2 - Use the PopupWindow method on the HtmlPage HtmlPage.PopupWindow(new Uri("http://www.bing.com"), "blah", new HtmlPopupWindowOptions()); This does not work. I get a new window every time. Option 3 - Get a handle to the opened window and reuse that in subsequent calls private HtmlWindow window; private void navigationButton_Click(object sender, RoutedEventArgs e) { if (window == null) window = HtmlPage.Window.Navigate(new Uri("http://www.bing.com"), "blah"); else window.Navigate(new Uri("http://www.bing.com"), "blah"); if (window == null) MessageBox.Show("it's null"); } This does not work. I tried the same for the PopupWindow() method and the window is null every time, so a new window is opened on every click. I have checked both the EnableHtmlAccess and the IsPopupWindowAllowed properties, and they return true, as they should. Option 4 - Use Eval method to execute some custom javascript private const string javascript = @"var popup = window.open('', 'blah') ; if(popup.location != 'http://www.bing.com' ){ popup.location = 'http://www.bing.com'; } popup.focus();"; private void navigationButton_Click(object sender, RoutedEventArgs e) { HtmlPage.Window.Eval(javascript); } This does not work. I get a new window every time. option 5 - Use CreateInstance to run some custom javascript on the page private void navigationButton_Click(object sender, RoutedEventArgs e) { HtmlPage.Window.CreateInstance("thisIsPlainHell"); } and in my aspx I have function thisIsPlainHell() { var popup = window.open('http://www.bing.com', 'blah'); popup.focus(); } Guess what? This does work. The only thing is that the window behaves a little strange and I'm not sure why: I'm behind a proxy and in all other scenarios I'm being prompted for my password. In this case however I am not (and am thus not able to reach the external site - bing in this case). This is not really a huge issue atm, but I just don't understand what's goign on here. Whenever I type another url in the address bar of the popup window (eg www.google.com) and press enter, it opens up another window and prompts me for my proxy password. As a temporary solution option 5 could do, but I don't like the fact that Silverlight is not able to manage this. One of the main reasons my client has opted for Silverlight is to be protected against all the browser specific hacking that comes with javascript. Am I doing something wrong? I'm definitely no javascript expert, so I'm hoping it's something obvious I'm missing here. Cheers, Phil

    Read the article

  • Custom UserControl property not being set via XAML DataBinding in Silverlight 4

    - by programatique
    I have a custom user control called GoalProgressControl. Another user control contains GoalProgressControl and sets its GoalName attribute via databinding in XAML. However, the GoalName property is never set. When I check it in debug mode GoalName remains "null" for the control's lifetime. How do I set the GoalName property? Is there something I am doing incorrectly? I am using .NET Framework 4 and Silverlight 4. I am relatively new to XAML and Silverlight so any help would be greatly appreciated. I have attempted to change GoalProgressControl.GoalName into a POCO property but this causes a Silverlight error, and my reading leads me to believe that databound properties should be of type DependencyProperty. I've also simplified my code to just focus on the GoalName property (the code is below) with no success. Here is GoalProgressControl.xaml: <UserControl x:Class="GoalView.GoalProgressControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" DataContext="{Binding RelativeSource={RelativeSource Self}}" Height="100"> <Border Margin="5" Padding="5" BorderBrush="#999" BorderThickness="1"> <TextBlock Text="{Binding GoalName}"/> </Border> </UserControl> GoalProgressControl.xaml.cs: public partial class GoalProgressControl : UserControl, INotifyPropertyChanged { public GoalProgressControl() { InitializeComponent(); } public event PropertyChangedEventHandler PropertyChanged; public void NotifyPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } public static DependencyProperty GoalNameProperty = DependencyProperty.Register("GoalName", typeof(string), typeof(GoalProgressControl), null); public string GoalName { get { return (String)GetValue(GoalProgressControl.GoalNameProperty); } set { base.SetValue(GoalProgressControl.GoalNameProperty, value); NotifyPropertyChanged("GoalName"); } } } I've placed GoalProgressControl on another page: <Grid Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Margin="5" Background="#eee" Height="200"> <Border BorderBrush="#999" BorderThickness="1" Background="White"> <StackPanel> <hgc:SectionTitleBar x:Name="ttlGoals" Title="Personal Goals" ImageSource="../Images/check.png" Uri="/Pages/GoalPage.xaml" MoreVisibility="Visible" /> <ItemsControl ItemsSource="{Binding Path=GoalItems}"> <ItemsControl.ItemTemplate> <DataTemplate> <!--TextBlock Text="{Binding Path=[Name]}"/--> <goal:GoalProgressControl GoalName="{Binding Path=[Name]}"/> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </StackPanel> </Border> </Grid> Please note the commented out "TextBlock" item above. If I comment in the TextBlock and comment out the GoalProgressControl, the binding works correctly and the TextBlock shows the GoalName correctly. Also, if I replace the "GoalName" property above with a simple text string (ex "hello world"), the control renders correctly and "hello world" is shown on the control when it renders.

    Read the article

  • XBAP childWindow control available similar to Silverlight 3 ChildWindow?

    - by some guy
    The Silverlight 3 toolkit has a ChildWindow control for model popup like functionality. This is great. Anyone aware of a similar control that can be utilized via XBAP? http://silverlight.codeplex.com/wikipage?title=Silverlight%20Toolkit%20Overview%20Part%204&referringTitle=Silverlight%20Toolkit%20Overview%20Part%203 The assumption is maybe someone ported the functionality back to WCF/XBAP? Trying to find a solution without going to 3rd party purchased controls (against current company policy).

    Read the article

  • COM Object Method Invoke Exception - Silverlight 4

    - by Adam Driscoll
    I'm trying to use the new AutomationFactory provided with Silverlight 4 to call a .NET COM class. .NET COM-Exposed Class: public class ObjectContainer { public bool GetObject([Out, MarshalAs((UnmanagedType.IUnknown)] out object obj) { obj = new SomeOtherObj(); return true; } } Silverlight Assembly: dynamic objectContainer; try { objectContainer = AutomationFactory.GetObject(ProgId); } catch { objectContainer = AutomationFactory.CreateObject(ProgId); } object obj; if (!objectContainer.GetObject(out obj)) { throw new Exception(); } When I call objectContainer.GetObject(out obj) an exception is thrown stating: Value does not fall within the expected range. at MS.Internal.ComAutomation.ComAutomationNative.CheckInvokeHResult(UInt32 hr, String memberName, String exceptionSource, String exceptionDescription, String exceptionHelpFile, UInt32 exceptionHelpContext) at MS.Internal.ComAutomation.ComAutomationNative.Invoke(Boolean tryInvoke, String memberName, ComAutomationInvokeType invokeType, ComAutomationInteropValue[] rgParams, IntPtr nativePeer, ComAutomationInteropValue& returnValue) at MS.Internal.ComAutomation.ComAutomationObject.InvokeImpl(Boolean tryInvoke, String name, ComAutomationInvokeType invokeType, Object& returnValue, Object[] args) at MS.Internal.ComAutomation.ComAutomationObject.Invoke(String name, ComAutomationInvokeType invokeType, Object[] args) at System.Runtime.InteropServices.Automation.AutomationMetaObjectProvider.TryInvokeMember(InvokeMemberBinder binder, Object[] args, Object& result) at System.Runtime.InteropServices.Automation.AutomationMetaObjectProviderBase.<.cctorb__4(Object obj, InvokeMemberBinder binder, Object[] args) at CallSite.Target(Closure , CallSite , Object , String , Object& ) at CallSite.Target(Closure , CallSite , Object , String , Object& ) at ApplicationModule.ObjectContainer.GetObject() Wha's the deal?

    Read the article

  • Silverlight ScriptableMember in Firefox 'Content is undefined' error.

    - by Sergey Mirvoda
    Recently I'm learned how to call SIlverlight methods from JavaScript. All works fine (even in Chrome !). But in FireFox 3 (3.6.4) registered Page object is undefined. My Code is very simple silverlight [ScriptableMember] public bool HasFilter() { return true; } And in MainPage constructor public MainPage() { InitializeComponent(); HtmlPage.RegisterScriptableObject("Page",this); LayoutRoot.DataContext = viewModel; Loaded += OnLoaded; } JavaScript <head> <script type="text/javascript"> function UpdateFilter() { var sl = document.getElementById('SilverlightChartControl'); alert(sl); alert(sl.Content.Page.HasFilter()); } </script> </head> <body> <a href="#" id="resize" onclick="UpdateFilter(); return false;">TEST</a> </body>

    Read the article

  • Silverlight 4 WriteableBitmap ScaleTransform Exception but was working in v3

    - by Imran
    I am getting the following exception for code that used to work in silverlight 3 but has stopped working since upgrading to silverlight 4: System.AccessViolationException was unhandled Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt. namespace SilverlightApplication1 { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); } private void button1_Click(object sender, RoutedEventArgs e) { var OpenFileDialog = new OpenFileDialog(); OpenFileDialog.Filter = "*.jpg|*.jpg"; if (OpenFileDialog.ShowDialog() == true) { var file = OpenFileDialog.Files.ToArray()[0]; ScaleStreamAsBitmap(file.OpenRead(), 200); } } public static WriteableBitmap ScaleStreamAsBitmap(Stream file, int maxEdgeLength) { file.Position = 0; var src = new BitmapImage(); var uiElement = new System.Windows.Controls.Image(); WriteableBitmap b = null; var t = new ScaleTransform(); src.SetSource(file); uiElement.Source = src; //force render uiElement.Effect = new DropShadowEffect() { ShadowDepth = 0, BlurRadius = 0 }; ; //calc scale double scaleX = 1; double scaleY = 1; if (src.PixelWidth > maxEdgeLength) scaleX = ((double)maxEdgeLength) / src.PixelWidth; if (src.PixelHeight > maxEdgeLength) scaleY = ((double)maxEdgeLength) / src.PixelHeight; double scale = Math.Min(scaleX, scaleY); t.ScaleX = scale; t.ScaleY = scale; b = new WriteableBitmap(uiElement, t); return b; } } } Thanks

    Read the article

  • Silverlight 2 Error Code: 4004

    - by jkidv
    Hey guys/gals. I have a silverlight 2 app that has an ObservableCollection of a class from a separate assem/lib. When I set my ListBox.ItemsSource on that collection, and run it, I get the error code: 4004 "System.ArgumentException: Value does not fall within the expected range." Here is part of the code: public partial class Page : UserControl { ObservableCollection<Some.Lib.Owner> ooc; public Page() { ooc = new ObservableCollection<Some.Lib.Owner>(); Some.Lib.Owner o1 = new Some.Lib.Owner() { FirstName = "test1" }; Some.Lib.Owner o2 = new Some.Lib.Owner() { FirstName = "test2" }; Some.Lib.Owner o3 = new Some.Lib.Owner() { FirstName = "test3" }; ooc.Add(o1); ooc.Add(o2); ooc.Add(o3); InitializeComponent(); lb1.ItemsSource = ooc; } } But when I create the Owner class within this same project, everything works fine. Is there some security things going on behind the scenes? Also, I'm using the generate a html page option and not the aspx option, when I created this Silverlight 2 app.

    Read the article

  • Silverlight: Problem using CellEditingTemplate

    - by Charles
    Hello Silverlight gurus, I am experiencing a problem with the DataGrid where my data-bound object's properties are not being updated when using the CellTemplate/CellEditingTemplate: <data:DataGridTemplateColumn Header="Text"> <data:DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Text}" ></TextBlock> </DataTemplate> </data:DataGridTemplateColumn.CellTemplate> <data:DataGridTemplateColumn.CellEditingTemplate> <DataTemplate> <TextBox Text="{Binding Text, Mode=TwoWay}" /> </DataTemplate> </data:DataGridTemplateColumn.CellEditingTemplate> </data:DataGridTemplateColumn> I am binding to a code-gen'd entity via the RIA Services. I've added an event handler to the PropertyChanged event, and it is never fired. However, if I do not use a template and instead use a DataGridTextColumn, everything works fine. I'm sure this sounds like an easy fix - I'm only using a TextBox in my editing template, so why not us a DataGridTextColumn? The problem is that I want to have a multi-line textbox, so using the DataGridTextColumn is not an option. Any suggestions? Do you know of any differences between using a CellEditingTemplate containing a single TextBox and using a DataGridTextColumn? Thanks, -Charles [UPDATE] I posted a bug report here: http://silverlight.net/forums/p/118729/267521.aspx I can't imagine that this is "as-designed"... If someone else has known about this and I'm just being dumb, I'd appreciate an explanation - I'd prefer embarrassment over ignorance :).

    Read the article

  • Starting out Silverlight 4 design

    - by Fermin
    I come from mainly a web development background (ASP.NET, ASP.NET MVC, XHTML, CSS etc) but have been tasked with creating/designing a Silverlight application. The application is utilising Bing Maps control for Silverlight, this will be contained in a user control and will be the 'main' screen in the system. There will be numerous other user controls on the form that will be used to choose/filter/sort/order the data on the map. I think of it like Visual Studio: the Bing Maps will be like the code editor window and the other controls will be like Solutions Explorer, Find Results etc. (although a lot less of them!) I have read up and I'm comfortable with the data side (RIA-Services) of the application. I've (kinda) got my head around databinding and using a view model to present data and keep the code behind file lite. What I do need some help on is UI design/navigation framework, specifically 2 aspects: How do I best implement a fluid design so that the various user controls which filter the map data can be resized/pinned/unpinned (for example, like the Solution Explorer in VS)? I made a test using a Grid with a GridSplitter control, is this the best way? Would it be best to create a Grid/Gridsplitter with Navigation Frames inside the grid to load the content? Since I have multiple user controls that basically use the same set of data, should I set the dataContext at the highest possible level (e.g. if using a grid with multiple frames, at the Grid level?). Any help, tips, links etc. will be very much appreciated!

    Read the article

  • PRISM - Creating mouseoverbehavior causes a Silverlight library to not be visible in main Silverligh

    - by RHLopez
    Created a simple Silverlight 4 application (SimpleApp) then added a Silverlight 4 library (LibraryA). Added code to the library (LibraryA) to implement MouseOverBehavior by inheriting from CommandBaseBehavior along with the appropriate attached property class/methods. Added reference in SimpleApp to LibraryA and went to MainPage.xaml to add namespace reference but it does not show up with Intellisense. Typing the namespace manually and then adding the attached MouseOver command works as it should as far as intellisense showing my attached property name, i.e. ... commands:MouseOver.Command="{Binding MousedOver}". However when I try to run it I get a XAML parser error saying that the "Command" attached property does not exist in MouseOver. If I move my class definitions from LibraryA to SimpleApp then everything works. I removed everything from LibraryA and just put one class with this in it: public class MouseOverBehavior : CommandBehaviorBase<Control> { public MouseOverBehavior(Control element) : base(element) {} } With this simple class in LibraryA it will not show up in XAML intellisense in SimpleApp. XAML intellisense works with other libraries that I have written that don't use PRISM. Don't know what I am missing hopefully it's something simple. I am using the latest SL4 build for PRISM change set 42969. Visual Studio 2010 RTM Professional in Windows 7 Ultimate 64-bit.

    Read the article

  • Issue intercepting property in Silverlight application

    - by joblot
    I am using Ninject as DI container in a Silverlight application. Now I am extending the application to support interception and started integrating DynamicProxy2 extension for Ninject. I am trying to intercept call to properties on a ViewModel and ending up getting following exception: “Attempt to access the method failed: System.Reflection.Emit.DynamicMethod..ctor(System.String, System.Type, System.Type[], System.Reflection.Module, Boolean)” This exception is thrown when invocation.Proceed() method is called. I tried two implementations of the interceptor and they both fail public class NotifyPropertyChangedInterceptor: SimpleInterceptor { protected override void AfterInvoke(IInvocation invocation) { var model = (IAutoNotifyPropertyChanged)invocation.Request.Proxy; model.OnPropertyChanged(invocation.Request.Method.Name.Substring("set_".Length)); } } public class NotifyPropertyChangedInterceptor: IInterceptor { public void Intercept(IInvocation invocation) { invocation.Proceed(); var model = (IAutoNotifyPropertyChanged)invocation.Request.Proxy; model.OnPropertyChanged(invocation.Request.Method.Name.Substring("set_".Length)); } } I want to call OnPropertyChanged method on the ViewModel when property value is set. I am using Attribute based interception. [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] public class NotifyPropertyChangedAttribute : InterceptAttribute { public override IInterceptor CreateInterceptor(IProxyRequest request) { if(request.Method.Name.StartsWith("set_")) return request.Context.Kernel.Get<NotifyPropertyChangedInterceptor>(); return null; } } I tested the implementation with a Console Application and it works alright. I also noted in Console Application as long as I had Ninject.Extensions.Interception.DynamicProxy2.dll in same folder as Ninject.dll I did not have to explicitly load DynamicProxy2Module into the Kernel, where as I had to explicitly load it for Silverlight application as follows: IKernel kernel = new StandardKernel(new DIModules(), new DynamicProxy2Module()); Could someone please help? Thanks

    Read the article

  • Dynamically add User Controls to a Silverlight 4 page

    - by PilotBob
    I am building an iGoogle like "dashboard" for our application with silverlight 4. Each users dashboard (which snapins and their positions) will be stored in the database. Each snap in is a user control, for example... AwesomeSnapin.xaml. On the dashboard page in silverlight I am retrieving the users dashboard which is a collection of snapin objects which include the information on the snapin. I can store the name of the page or the class or whatever is needed. I have the following code which loops through the collection of snapins to add them to the dashboard page. In testing I have just hard coded a single snapin item. Here is the prototype code: foreach (var UserSnapin in op.Entities) { UserControl uc = new AmsiSL.eFinancials.BudgetCheck(); Canvas.SetLeft(uc, UserSnapin.PositionLeft); Canvas.SetTop(uc, UserSnapin.PositionTop); Layout.Children.Add(uc); MessageBox.Show(String.Format("Added {0}",UserSnapin.Snapin.Name)); } The above works fine... but of course adds the BudgetCheck snapin for every item that is defined for the users dashboard. Of course the messagebox is for debugging purposes only. How would I change line 3 of that to load the user control class (using classname or xaml path whichever is better) based on the data in the collection.

    Read the article

  • How to detect back button or forward button navigation in a silverlight navigation application

    - by parapura rajkumar
    When a Page is navigated to in silverlight you can override this method. protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); } The NavigationEventArgs has a NavigationMode enumeration which is defined as public enum NavigationMode { New = 0, Back = 1, Forward = 2, Refresh = 3, } But calling e.NavigationMode always throws a NotImplementedException Is there a way in silverlight to detect a page is being navigated to because the user hit the forward/back browser button. What I am trying to achieve is some kind of state that can be preserved when the user hits the back button. For example assume you have a customer page which is showing a list of customers in a datagrid. The user can select a customer and there is a detail view which shows all the orders for that customer. Now within an order item you can click a hyperlink link that takes you to the shipping history of the order which is a separate page. When the user hits the back button I want to go back to the customers page and automatically select the customer he was viewing. Is this possible at all ? I also tried out the fragment navigation feature NavigationService.Navigate(new Uri("#currentcustomerid=" + customer.Id.ToString(), UriKind.Relative)); when the customer selection changes but this adds too many items to the history when the user clicks various customers on the customer page. EDIT There is also an method you can override protected override void OnNavigatingFrom(NavigatingCancelEventArgs e) { } which is the same as handling the NavigationService.Navigating event as indicated by BugFinder's answer. In this method e.NavigationMode always returns New when when you hit the Back or Forward Button. The only time this method returns Back is when you explicitly call NavigationService.GoBack()

    Read the article

  • One-sided rounded buttons in Silverlight

    - by xarzu
    I want to make a collection of buttons in silverlight. They are in a collection that goes from left to right and the buttons are lined up so that they are touching on the left and right sides. Here is the rub: The collection has rounded corners but the buttons in between the end buttons in the collection do not have rounded ends. So basically, for the buttons on the far left and right side of the collection, they have to be somewhat special because they have to have one flat vertical side and one rounded side. Is this possible to do in silverlight without resorting to making a special bitmap for the end buttons? One idea I have is somehow declare a canvas with a bitmap background and then have overlapping ellipse and rectangle <Canvas Height="100" HorizontalAlignment="Left" Margin="189,381,0,0" VerticalAlignment="Top" Width="200" Background="Black"> <Rectangle Fill="#FFF4F4F5" HorizontalAlignment="Left" Stroke="Black" Width="58" Height="61" Canvas.Left="7" Canvas.Top="16" /> <Ellipse Fill="#FFF4F4F5" HorizontalAlignment="Left" Stroke="White" Width="65" StrokeThickness="0" Height="59" Canvas.Left="31" Canvas.Top="17" /> </Canvas>

    Read the article

  • Silverlight 3.0 Custom Cursor in Chart

    - by Wonko the Sane
    Hello All, I'm probably overlooking something that will be obvious when I see the solution, but for now... I am attempting to use a custom cursor inside the chart area of a Toolkit chart. I have created a ControlTemplate for the chart, and a grid to contain the cursors. I show/hide the cursors, and attempt to move the containing Grid, using various Mouse events. The cursor is being displayed at the correct times, but I cannot get it to move to the correct position. Here is the ControlTemplate (the funky colors are just attempts to confirm what the different pieces of the template pertain to): <dataVisTK:Title Content="{TemplateBinding Title}" Style="{TemplateBinding TitleStyle}"/> <Grid Grid.Row="1"> <!-- Remove the Legend --> <!--<dataVisTK:Legend x:Name="Legend" Title="{TemplateBinding LegendTitle}" Style="{TemplateBinding LegendStyle}" Grid.Column="1"/>--> <chartingPrimitivesTK:EdgePanel x:Name="ChartArea" Background="#EDAEAE" Style="{TemplateBinding ChartAreaStyle}" Grid.Column="0"> <Grid Canvas.ZIndex="-1" Background="#2008AE" Style="{TemplateBinding PlotAreaStyle}"> </Grid> <Border Canvas.ZIndex="1" BorderBrush="#FF250010" BorderThickness="3" /> <Grid x:Name="gridHandCursors" Canvas.ZIndex="5" Width="32" Height="32" Visibility="Collapsed"> <Image x:Name="cursorGrab" Width="32" Source="Resources/grab.png" /> <Image x:Name="cursorGrabbing" Width="32" Source="Resources/grabbing.png" Visibility="Collapsed"/> </Grid> </chartingPrimitivesTK:EdgePanel> </Grid> </Grid> </Border> and here are the mouse events (in particular, the MouseMove): void TimelineChart_Loaded(object sender, RoutedEventArgs e) { chartTimeline.UpdateLayout(); List<FrameworkElement> chartChildren = GetLogicalChildrenBreadthFirst(chartTimeline).ToList(); mChartArea = chartChildren.Where(element => element.Name.Equals("ChartArea")).FirstOrDefault() as Panel; if (mChartArea != null) { grabCursor = chartChildren.Where(element => element.Name.Equals("cursorGrab")).FirstOrDefault() as Image; grabbingCursor = chartChildren.Where(element => element.Name.Equals("cursorGrabbing")).FirstOrDefault() as Image; mGridHandCursors = chartChildren.Where(element => element.Name.Equals("gridHandCursors")).FirstOrDefault() as Grid; mChartArea.Cursor = Cursors.None; mChartArea.MouseMove += new MouseEventHandler(mChartArea_MouseMove); mChartArea.MouseLeftButtonDown += new MouseButtonEventHandler(mChartArea_MouseLeftButtonDown); mChartArea.MouseLeftButtonUp += new MouseButtonEventHandler(mChartArea_MouseLeftButtonUp); if (mGridHandCursors != null) { mChartArea.MouseEnter += (s, e2) => mGridHandCursors.Visibility = Visibility.Visible; mChartArea.MouseLeave += (s, e2) => mGridHandCursors.Visibility = Visibility.Collapsed; } } } void mChartArea_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (grabCursor != null) grabCursor.Visibility = Visibility.Visible; if (grabbingCursor != null) grabbingCursor.Visibility = Visibility.Collapsed; } void mChartArea_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (grabCursor != null) grabCursor.Visibility = Visibility.Collapsed; if (grabbingCursor != null) grabbingCursor.Visibility = Visibility.Visible; } void mChartArea_MouseMove(object sender, MouseEventArgs e) { if (mGridHandCursors != null) { Point pt = e.GetPosition(null); mGridHandCursors.SetValue(Canvas.LeftProperty, pt.X); mGridHandCursors.SetValue(Canvas.TopProperty, pt.Y); } } Any help past this roadblock would be greatly appreciated! Thanks, wTs

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >