Search Results

Search found 8559 results on 343 pages for 'silverlight navigation'.

Page 60/343 | < Previous Page | 56 57 58 59 60 61 62 63 64 65 66 67  | Next Page >

  • Limiting the width of a TextBlock in Silverlight

    - by Druzil
    The obvious MaxWidth gets ignored and the text in the "DisplayBox" TextBlock displays the whole text even if this text continues past the parent container controls (to the edge of the silverlight area. <win:HierarchicalDataTemplate x:Key="hierarchicalTemplate" ItemsSource="{Binding _children}"> <Border BorderThickness="0" BorderBrush="Orange" HorizontalAlignment="Stretch" Background="{Binding Converter={StaticResource BackgroundConverter}}"> <toolkit:DockPanel LastChildFill="True" Width="{Binding HeirarchyLevel, Converter={StaticResource WidthConverter}}" Height="20"> <Canvas toolkit:DockPanel.Dock="Right" Width="20" MouseLeftButtonUp="Arrow_MouseLeftButtonDown"> <Rectangle Width="20" Height="20" Fill="Transparent" /> <Line Stroke="Black" X1="5" Y1="10" X2="17" Y2="10" /> <Line Stroke="Black" X1="11" Y1="5" X2="17" Y2="10" /> <Line Stroke="Black" X1="11" Y1="15" X2="17" Y2="10" /> </Canvas> <Ellipse Canvas.Top="5" Width="10" Height="10" Fill="Green" toolkit:DockPanel.Dock="Right" MouseLeftButtonDown="Ellipse_MouseLeftButtonDown" /> <Canvas Width="Auto" Loaded="TextArea_Loaded"> <TextBlock Name="DisplayBox" FontFamily="Arial" FontSize="17" Foreground="Black" Width="Auto" Text="{Binding TaskName}" MouseLeftButtonUp="TextBlock_MouseLeftButtonUp" /> <TextBox Name="EditBox" FontFamily="Arial" FontSize="10" Foreground="Black" Height="20" Text="{Binding TaskName}" Visibility="Collapsed" LostFocus="TextBox_LostFocus" /> <Line Stroke="Black" X1="0" Y1="10" X2="202" Y2="10" Width="Auto" /> </Canvas> </toolkit:DockPanel> </Border> </win:HierarchicalDataTemplate>

    Read the article

  • Silverlight Timer problem

    - by jose
    Hello, I am developing a Silverlight application with custom animations. I want to update the variable animationCounter every 1 milissecond, so that in one second the value is 1000. I've tried DispatcherTimer and System.Threading.Timer. this way: DispatcherTimer timer = new DispatcherTimer(); (...) timer.Interval = new TimeSpan(0, 0, 0, 0, 1); timer.Tick += new EventHandler(timer_Tick); (...) (...) void timer_Tick(object sender, EventArgs e) { animationCounter++; Dispatcher.BeginInvoke(() => txtAnimationCounter.Text = animationCounter.ToString()); } with System.Threading.Timer System.Threading timer = null; timer = new System.Threading.Timer(UpdateAnimationCounter, 0, 1); void UpdateAnimationCounter(object state) { animationCounter++; Dispatcher.BeginInvoke(() => txtAnimationCounter.Text = animationCounter.ToString()); } Both of them are setting AnimationCounter around 100 in one second. Should be 1000. I don't know why. Is there anything I'm missing. Thanks

    Read the article

  • Silverlight Image Data Binding

    - by Alexander
    I am new to Silverlight, and have an issue with binding. I have a class ItemsManager, that has inside its scope another class Item. class ItemsManager { ... class Item : INotifyPropertyChanged { ... private BitmapImage bitmapSource; public BitmapImage BitmapSource { get { return bitmapSource; } set { bitmapSource = value; if(PropertyChanged != null )PropertyChanged("BitmapSource") } } } } I do the following in code to test binding: { ItemsManager.Instance.AddItem("123"); //Items manager started downloading item visual //part (in my case bitmap image png) Binding b = new Binding("Source"); b.Source = ItemsManager.Instance.GetItem("123").BitmapSource; b.BindsDirectlyToSource = true; Image img = new Image(); img.SetBinding(Image.SourceProperty, b); img.Width = (double)100.0; img.Height = (double)100.0; LayoutRoot.Children.Add(img); } Once image is loaded, image doesn't appear. Though, if I set directly after image has been loaded its source, it displays well. I also noticed that PropertyChanged("BitmapSource") never fires, because PropertyChanged is null, like Image never binded to it. I am looking forward to hearing from you!

    Read the article

  • Silverlight logging out causes "Object reference not set to an instance"

    - by Alex
    I am using the Silverlight 4 Business Application Template. I've created a DomainDataSource in XAML like so: <riaControls:DomainDataSource x:Name="LogData" QueryName="GetLogs" AutoLoad="True" LoadSize="20" > <riaControls:DomainDataSource.DomainContext> <local:AdminDomainContext /> </riaControls:DomainDataSource.DomainContext> <riaControls:DomainDataSource.QueryParameters> <riaControls:Parameter ParameterName="UserLoginID" Value="{Binding Path=User.UserLoginID, Source={StaticResource WebContext}}" /> </riaControls:DomainDataSource.QueryParameters> </riaControls:DomainDataSource> The problem I'm experiencing is that whenever I log out, I get: Load operation failed for query 'GetLogs'. Object reference not set to an instance of an object. I assume that because I've logged out, User.UserLoginID is now null and is causing the exception. So... anybody know a good way for me to solve this? I don't really want to set the QueryParameter programmatically.

    Read the article

  • Silverlight: Button template with texttrimming cut off

    - by dex3703
    I'm replacing the default Button template's ContentPresenter with a TextBlock, so the text can be trimmed when it's too long. Works fine in WPF. In Silverlight the text gets pushed to one edge and cut off on the left, even when there's space on the right: Template is nothing special, just replaced the ContentPresenter with the TextBlock: <Border x:Name="bdrBackground" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" /> <Rectangle x:Name="rectMouseOverVisualElement" Opacity="0"> <Rectangle.Fill> <SolidColorBrush x:Name="rectMouseOverColor" Color="{StaticResource MouseOverItemBgColor}"/> </Rectangle.Fill> </Rectangle> <Rectangle x:Name="rectPressedVisualElement" Opacity="0" Style="{TemplateBinding Tag}"/> <TextBlock x:Name="textblock" Text="{TemplateBinding Content}" TextTrimming="WordEllipsis" TextWrapping="NoWrap" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/> <Rectangle x:Name="rectDisabledVisualElement" Opacity="0" Style="{StaticResource RectangleDisabledStyle}"/> <Rectangle x:Name="rectFocusVisualElement" Opacity="0" Style="{StaticResource RectangleFocusStyle}"/> </Grid> </ControlTemplate> How do I fix this? More info: With the latest comment about HorizontalAlignment, it's clear that SL's implementation of TextTrimming differs from WPF's. In SL, TextTrimming only really works if the text is aligned left. SL isn't smart enough to align the text the way WPF does. For instance: WPF button: SL button with the textblock horizontalalignment = left: SL button with textblock horizontalalignment = center:

    Read the article

  • WCF operationcontract with List type unavailable in (Silverlight) client

    - by Dave
    This is the first time I have tried returning a List of data to a Silverlight client, so I'm having trouble getting the client to recognize this operationcontract. All others are fine. I have a method on the server called ReadOwFileData that needs to return a List. ReadOwFileDataCompletedEventArgs shows up in the Object Browser in the client, but not ReadOwFileDataAsync. What I want is similar to the tutorial here. The Dictionary collection type on the client is set to System.Collections.Generic.List. I tried deleting and recreating the service reference. Web.Config on the server is using basicHttpBinding. Here is the operationcontract on the server: [OperationContract] public List<OwFileData> ReadOwFileData(string OrderID) { DataClasses1DataContext db = new DataClasses1DataContext(); var dFileData = (from p in db.OwFileDatas where p.OrderID == OrderID select p).ToList(); List<OwFileData> x = new List<OwFileData>(dFileData); return x; } Incidently, this works fine: [OperationContract] public Customer GetShippingAndContactInfo(string login, string ordernum) { DataClasses1DataContext db = new DataClasses1DataContext(); Customer dInfo = (from p in db.Customers where p.Login == login select p).Single(); return dInfo; } I would like to read this data in the client and place it into an object I created called ObservableCollection. But that obviously can't happen until the client can see the method on the server. I do not know if this is an acceptable start, but this is what is on the client so far. The ReadOwFileDataAsync object is null: void populatefilesReceivedDataSource(string OrderID) { ArtUpload.ServiceReference1.UploadServiceClient client = new ArtUpload.ServiceReference1.UploadServiceClient(); var myList = client.ReadOwFileDataAsync(OrderID); // can I just itterate thru the list instead of 'binding' }

    Read the article

  • Accessing my own datalayer using RIA & Silverlight

    - by Norsten
    Is it possible for me to connect to my own data provide via WCF RIA services? I've created a small datalayer that connnects to DynamicAX datasource. I would like to use Silverlight 4 & RIA service to access that datalayer. At it's most basic -I've done the following... 1) I've added an empty domainclass to the webproject and in that class I created a simple method to return a string... [EnableClientAccess()] public class ProjectService : DomainService { public string TestViaRIA() { return "Hello!"; } } 2) I then added reference to the web project in my silvelight class and created a bit of code to try and invoke the method... using ProjectApp.Web; namespace ProjectApp.Views { public partial class ProjectControl : UserControl { public ProjectControl() { InitializeComponent(); ProjectContext ctx = new ProjectContext(); var x = ctx.TestViaRIA(); testTextBox.Text = x.ToString(); } } } the returned value is "{System.ServiceModel.DomainServices.Client.InvokeOperation}". I'm obviously doing something wrong here and I would appreciate some guidance on how I can achive this. Thanks in advance

    Read the article

  • Scroll to item in listview in Silverlight 3.

    - by the empirical programmer
    I have a silverlight 3 app with a textbox on the main window and a childwindow that has a list of all the potential textbox values. When I open that childwindow I want it to scroll to the correct one in the list. I'm trying to do this with the code below...using the ScrollIntoView. It was not working at all until I add the UpdateLayerout(). However it does not seem to work all the time. At times it scrolls but not all the way to the item, it is a few items higher than it should be. The listbox is in an Accordion and the list items use a ItemTemplate\DataTemplate, not sure if that effects anything but thought I'd mention it. Any ideas what I'm missing in the code below? What I would like is to scroll the item to the top of the list ....any ideas how to that? (Or any other suggestions on how to code this better) Thanks! for (int index = 0; index < myList.Items.Count; index++) { object obj = myList.Items[index]; var listItem= obj as listItemObject; if (listItemObj != null) { if (string.Compare(listItemObj.id, _PastedInId, StringComparison.InvariantCultureIgnoreCase) == 0) { selectThisIndex = index; scrollToThisItem = obj; } } } myList.SelectedIndex = selectThisIndex; if (scrollToThisItem != null){ myList.UpdateLayout(); myList.ScrollIntoView(scrollToThisItem); }

    Read the article

  • Silverlight: Why doesn't this binding expression work?

    - by Rosarch
    I'm having difficulty with a binding expression in Silverlight 3 for the Windows Phone 7. <Grid x:Name="LayoutRoot" Background="Transparent"> <controls:Pivot ItemsSource="{Binding SectionViewModels}"> <!-- ... --> <controls:Pivot.ItemTemplate> <DataTemplate> <Grid> <!-- this is the troublesome binding --> <TextBlock Style="{StaticResource disabledText}" Visibility="{Binding ElementName=LayoutRoot, Path=DataContext.NoStoryContent}"> Do you have a network connection? </TextBlock> <!-- ... --> The style, in app.xaml: <Style x:Key="disabledText" TargetType="TextBlock"> <Setter Property="Foreground" Value="{StaticResource PhoneDisabledBrush}" /> <Setter Property="TextWrapping" Value="Wrap" /> <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeLarge}" /> </Style> Code behind: public Visibility NoStoryContent { get { // trivial return value for debugging // no breakpoint here is hit return Visibility.Collapsed; } } public Sections() { InitializeComponent(); LayoutRoot.DataContext = this; } What am I doing wrong here? I suspect I have a mistake in the binding expression, but I'm not sure where.

    Read the article

  • PDF reviewer in C# (ASP.NET/Silverlight?)

    - by Anders Holmström
    Hi. I'm essentially planning to mimic the comment functions on PDF files, but online. That is; a user should be able to log in and upload a PDF file, and then numerous different users should be able to add comments etc to this same file (and view the file, with comments, online). External libraries are ok. Free obviously preferred, but commercial ones are fine if they provide a lot of the needed functionality. Note that this is meant to be used in a commercial environment. Comments don't necessarily need to be able to be exported from the site. I.e. if the comments are just put as a layer on top of a PDF file (and not in the actual file) that's ok. But obviously the more export functionality the better. I have looked at a few libraries (using the related questions and google) and while I find some that seem to do sort of what I want I'm not sure they are the bee's knees plus I would like to do as much myself as possible. The three basic approaches I've thought of is: Use some sort of native PDF viewing and then just smack down a layer on top of it where you can move around comments etc. Convert PDFs to HTML and work from there. Problem here it would either require proper PDFs (e.g. non-scanned) or really good OCR which seems a bit tedious. Convert PDFs to images and work from there. I'm afraid this will create massive images however. We're talking PDFs that can be hundreds of pages. One option would of course to just display one PDF page (image) at a time. And last - should I look at Silverlight for this or go with ASP.NET? Ideas and input concerning this project are much appreciated.

    Read the article

  • Why do different versions of Silverlight assemblies have the same version number?

    - by Simon
    Why do different versions of Silverlight assemblies have the same version number? Location: ...\Silverlight\v3.0\System.Core.dll Name: System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e Location: ...\Silverlight\v4.0\System.Core.dll Name: System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e Location: ...\Silverlight\v4.0\Profile\WindowsPhone\System.Core.dll Name: System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e While standard .net has different version numbers Location: ...\Framework\v4.0.30319\System.dll Name: System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Location: ...\Framework\v2.0.50727\System.dll Name: System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

    Read the article

  • Silverlight and Unexpected Font Sizes

    - by Eric J.
    Someone please teach me to fish here... I'm just learning Silverlight and have ran into a few situations where the font size actually used is drastically different than I would expect. There's probably something conceptual that I'm missing. Case A In one instance, I have defined a user control that presents a Label to show text. If one clicks on the label, the label (that is in a stack panel, in the user control) is replaced with a TextBox. When used at the top of a page (as in the example below with lblName) the label text is very small (around 8 points). When clicked on, the text box that replaces the label uses the specified fonts size. That same user control, used in different parts of the app, uses the same font for Label and TextBox. <Grid x:Name="LayoutRoot" Background="White"> <Grid.RowDefinitions> <RowDefinition Height="33" /> <RowDefinition Height="267*" /> </Grid.RowDefinitions> <StackPanel Height="Auto" HorizontalAlignment="Left" Name="stackPanel" VerticalAlignment="Top" Width="Auto" Grid.Row="1" /> <my:EditLabel Height="33" HorizontalAlignment="Left" x:Name="lblName" VerticalAlignment="Top" Width="Auto" FlexText="{Binding Name, Mode=TwoWay}" FontSize="20" MinHeight="24" /> </Grid> Case B I'm using the LiquidMenu.Menu control to pop up a menu when a button is pressed. The font looks huge compared to the rest of my page (maybe 36 points?). I tried forcing it to a very small by explicitly setting it to 8pt, but that had no effect. <Grid x:Name="LayoutRoot" Background="{x:Null}"> <StackPanel x:Name="labelStackPanel" Orientation="Horizontal"> <TextBlock Height="24" HorizontalAlignment="Left" Name="labelText" VerticalAlignment="Top" Width="200" Text="(Value Goes Here)" /> </StackPanel> <liquidMenu:Menu x:Name="popupMenu" Canvas.Left="40" Canvas.Top="40" ItemSelected="MenuList_ItemSelected" Visibility="Collapsed" Height="Auto" FontSize="8"> <liquidMenu:MenuItem ID="delete" Icon="Images/Delete10.png" Text="Delete" Shortcut="Del" /> <liquidMenu:MenuItem ID="exclusive" Icon="" Text="Exclusive" Shortcut="Ctrl+E" /> <liquidMenu:MenuItem ID="properties" Icon="" Text="Properties" Shortcut="Ctrl+P" /> </liquidMenu:Menu> </Grid> Answers to these specific issues are great, a new way to think about this type of issue so that I understand how to control font size is better.

    Read the article

  • CheckBox Command Behaviors for Silverlight MVVM Pattern

    - by Blake Blackwell
    I am trying to detect when an item is checked, and which item is checked in a ListBox using Silverlight 4 and the Prism framework. I found this example on creating behaviors, and tried to follow it but nothing is happening in the debugger. I have three questions: Why isn't my command executing? How do I determine which item was checked (i.e. pass a command parameter)? How do I debug this? (i.e. where can I put break points to begin stepping into this) Here is my code: View: <ListBox x:Name="MyListBox" ItemsSource="{Binding PanelItems, Mode=TwoWay}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <CheckBox IsChecked="{Binding Enabled}" my:Checked.Command="{Binding Check}" /> <TextBlock x:Name="DisplayName" Text="{Binding DisplayName}"/> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> ViewModel: public MainPageViewModel() { _panelItems.Add( new PanelItem { Enabled = true, DisplayName = "Test1" } ); Check = new DelegateCommand<object>( itemChecked ); } public void itemChecked( object o ) { //do some stuff } public DelegateCommand<object> Check { get; set; } Behavior Class public class CheckedBehavior : CommandBehaviorBase<CheckBox> { public CheckedBehavior( CheckBox element ) : base( element ) { element.Checked +=new RoutedEventHandler(element_Checked); } void element_Checked( object sender, RoutedEventArgs e ) { base.ExecuteCommand(); } } Command Class public static class Checked { public static ICommand GetCommand( DependencyObject obj ) { return (ICommand) obj.GetValue( CommandProperty ); } public static void SetCommand( DependencyObject obj, ICommand value ) { obj.SetValue( CommandProperty, value ); } public static readonly DependencyProperty CommandProperty = DependencyProperty.RegisterAttached( "Command", typeof( CheckBox ), typeof( Checked ), new PropertyMetadata( OnSetCommandCallback ) ); public static readonly DependencyProperty CheckedCommandBehaviorProperty = DependencyProperty.RegisterAttached( "CheckedCommandBehavior", typeof( CheckedBehavior ), typeof( Checked ), null ); private static void OnSetCommandCallback( DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e ) { CheckBox element = dependencyObject as CheckBox; if( element != null ) { CheckedBehavior behavior = GetOrCreateBehavior( element ); behavior.Command = e.NewValue as ICommand; } } private static CheckedBehavior GetOrCreateBehavior( CheckBox element ) { CheckedBehavior behavior = element.GetValue( CheckedCommandBehaviorProperty ) as CheckedBehavior; if( behavior == null ) { behavior = new CheckedBehavior( element ); element.SetValue( CheckedCommandBehaviorProperty, behavior ); } return behavior; } public static CheckedBehavior GetCheckCommandBehavior( DependencyObject obj ) { return (CheckedBehavior) obj.GetValue( CheckedCommandBehaviorProperty ); } public static void SetCheckCommandBehavior( DependencyObject obj, CheckedBehavior value ) { obj.SetValue( CheckedCommandBehaviorProperty, value ); } } I used this article to get me started, but I'll readily admit this is over my head.

    Read the article

  • Binding to a dictionary in Silverlight with INotifyPropertyChanged

    - by rip
    In silverlight, I can not get INotifyPropertyChanged to work like I want it to when binding to a dictionary. In the example below, the page binds to the dictionary okay but when I change the content of one of the textboxes the CustomProperties property setter is not called. The CustomProperties property setter is only called when CustomProperties is set and not when the values within it are set. I am trying to do some validation on the dictionary values and so am looking to run some code when each value within the dictionary is changed. Is there anything I can do here? C# public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); MyEntity ent = new MyEntity(); ent.CustomProperties.Add("Title", "Mr"); ent.CustomProperties.Add("FirstName", "John"); ent.CustomProperties.Add("Name", "Smith"); this.DataContext = ent; } } public class MyEntity : INotifyPropertyChanged { public event PropertyChangedEventHandler System.ComponentModel.INotifyPropertyChanged.PropertyChanged; public delegate void PropertyChangedEventHandler(object sender, System.ComponentModel.PropertyChangedEventArgs e); private Dictionary<string, object> _customProps; public Dictionary<string, object> CustomProperties { get { if (_customProps == null) { _customProps = new Dictionary<string, object>(); } return _customProps; } set { _customProps = value; if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("CustomProperties")); } } } } VB Partial Public Class MainPage Inherits UserControl Public Sub New() InitializeComponent() Dim ent As New MyEntity ent.CustomProperties.Add("Title", "Mr") ent.CustomProperties.Add("FirstName", "John") ent.CustomProperties.Add("Name", "Smith") Me.DataContext = ent End Sub End Class Public Class MyEntity Implements INotifyPropertyChanged Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged Private _customProps As Dictionary(Of String, Object) Public Property CustomProperties As Dictionary(Of String, Object) Get If _customProps Is Nothing Then _customProps = New Dictionary(Of String, Object) End If Return _customProps End Get Set(ByVal value As Dictionary(Of String, Object)) _customProps = value RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("CustomProperties")) End Set End Property End Class Xaml <TextBox Height="23" Name="TextBox1" Text="{Binding Path=CustomProperties[Title], Mode=TwoWay}" /> <TextBox Height="23" Name="TextBox2" Text="{Binding Path=CustomProperties[FirstName], Mode=TwoWay}" /> <TextBox Height="23" Name="TextBox3" Text="{Binding Path=CustomProperties[Name], Mode=TwoWay}" />

    Read the article

  • MapItemsControls not updating Silverlight Bing Map

    - by Matt
    I'm using a MapItemsControl to control my Pushpin items within my Bing silverlight map. Right on the page load, I add a new pin programatically, and the pin shows up on the map. However I've now taken it further and I'm adding pins to my datasource via a click on the map. The new pins add to my datasource, but do not show up on the map. Do I need to rebind my datasource to my map control or somehow refresh the datasource? Here's some code <UserControl.Resources> <DataTemplate x:Key="PinData"> <m:Pushpin Location="{Binding Location}" PositionOrigin="BottomCenter" Width="Auto" Height="Auto" Cursor="Hand"> <m:Pushpin.Template> <ControlTemplate> <Grid> <myTestApp:MasterPin DataContext="{Binding}"/> </Grid> </ControlTemplate> </m:Pushpin.Template> </m:Pushpin> </DataTemplate> </UserControl.Resources> <Grid x:Name="LayoutRoot" Background="White"> <m:Map x:Name="myMap" CredentialsProvider="" Mode="Road" ScaleVisibility="Collapsed" > <m:MapItemsControl x:Name="mapItems" ItemTemplate="{StaticResource PinData}"/> </m:Map> </Grid> public partial class Map : UserControl { private List< BasePin > dataSource = new List< BasePin >(); public Map() { InitializeComponent(); _Initialize(); } private void _Initialize() { //this part works and adds a pin to the map dataSource.Add( new BaseSite( -33.881532, 18.440208 ) ); myMap.MouseClick += Map_MouseClick; mapItems.ItemsSource = dataSource; } public void Map_MouseClick(object sender, MapMouseEventArgs e)) { BasePin pin = new BasePin(); pin.Location = myMap.ViewportPointToLocation( e.ViewportPoint ); dataSource.Add( pin ); } }

    Read the article

  • C# Silverlight - Delay Child Window Load?!

    - by Goober
    The Scenario Currently I have a C# Silverlight Application That uses the domainservice class and the ADO.Net Entity Framework to communicate with my database. I want to load a child window upon clicking a button with some data that I retrieve from a server-side query to the database. The Process The first part of this process involves two load operations to load separate data from 2 tables. The next part of the process involves combining those lists of data to display in a listbox. The Problem The problem with this is that the first two asynchronous load operations haven't returned the data by the time the section of code to combine these lists of data is reached, thus result in a null value exception..... Initial Load Operations To Get The Data: public void LoadAudits(Guid jobID) { var context = new InmZenDomainContext(); var imageLoadOperation = context.Load(context.GetImageByIDQuery(jobID)); imageLoadOperation.Completed += (sender3, e3) => { imageList = ((LoadOperation<InmZen.Web.Image>)sender3).Entities.ToList(); }; var auditLoadOperation = context.Load(context.GetAuditByJobIDQuery(jobID)); auditLoadOperation.Completed += (sender2, e2) => { auditList = ((LoadOperation<Audit>)sender2).Entities.ToList(); }; } I Then Want To Execute This Immediately: IEnumerable<JobImageAudit> jobImageAuditList = from a in auditList join ai in imageList on a.ImageID equals ai.ImageID select new JobImageAudit { JobID = a.JobID, ImageID = a.ImageID.Value, CreatedBy = a.CreatedBy, CreatedDate = a.CreatedDate, Comment = a.Comment, LowResUrl = ai.LowResUrl, }; auditTrailList.ItemsSource = jobImageAuditList; However I can't because the async calls haven't returned with the data yet... Thus I have to do this (Perform the Load Operations, Then Press A Button On The Child Window To Execute The List Concatenation and binding): private void LoadAuditsButton_Click(object sender, RoutedEventArgs e) { IEnumerable<JobImageAudit> jobImageAuditList = from a in auditList join ai in imageList on a.ImageID equals ai.ImageID select new JobImageAudit { JobID = a.JobID, ImageID = a.ImageID.Value, CreatedBy = a.CreatedBy, CreatedDate = a.CreatedDate, Comment = a.Comment, LowResUrl = ai.LowResUrl, }; auditTrailList.ItemsSource = jobImageAuditList; } Potential Ideas for Solutions: Delay the child window displaying somehow? Potentially use DomainDataSource and the Activity Load control?! Any thoughts, help, solutions, samples comments etc. greatly appreciated.

    Read the article

  • BounceEase and silverlight 4 BarSeries

    - by Pharabus
    Hi, I am trying to get a bar series to "bounce" when drawing, I assumed the BounceEase TransitionEasingFunction would do this but the lines just fade in, I have posted the xaml and code behind below, does anyone know where I have gone wrong or is it more complex than I though, I am fairly new to silverlight XAML <Grid x:Name="LayoutRoot" Background="White"> <chartingToolkit:Chart x:Name="MyChart"> <chartingToolkit:BarSeries Title="Sales" ItemsSource="{Binding}" IndependentValuePath="Name" DependentValuePath="Value" AnimationSequence="FirstToLast" TransitionDuration="00:00:3"> <chartingToolkit:BarSeries.TransitionEasingFunction> <BounceEase EasingMode="EaseInOut" Bounciness="5" /> </chartingToolkit:BarSeries.TransitionEasingFunction> <chartingToolkit:BarSeries.DataPointStyle> <Style TargetType="Control"> <Setter Property="Background" Value="Red"/> </Style> </chartingToolkit:BarSeries.DataPointStyle> </chartingToolkit:BarSeries> <chartingToolkit:Chart.Axes> <chartingToolkit:LinearAxis Title="Types owned" Orientation="X" Minimum="0" Maximum="300" Interval="10" ShowGridLines="True" FontStyle='Italic'/> </chartingToolkit:Chart.Axes> </chartingToolkit:Chart> </Grid> code behind public class MyClass : DependencyObject { public string Name { get; set; } public Double Value { get { return (Double)GetValue(myValueProperty); } set{SetValue(myValueProperty,value);} } public static readonly DependencyProperty myValueProperty = DependencyProperty.Register("Value", typeof(Double), typeof(MyClass), null); } public MainPage() { InitializeComponent(); //Get the data IList<MyClass> l = this.GetData(); //Get a reference to the SL Chart MyChart.DataContext = l.OrderBy(e => e.Value); //Find the highest number and round it up to the next digit DispatcherTimer myDispatcherTimer = new DispatcherTimer(); myDispatcherTimer.Interval = new TimeSpan(0, 0, 0, 5, 0); // 100 Milliseconds myDispatcherTimer.Tick += new EventHandler(Each_Tick); myDispatcherTimer.Start(); } public void Each_Tick(object o, EventArgs sender) { ((BarSeries)MyChart.Series[0]).DataContext = GetData(); } private IList<MyClass> GetData() { Random random = new Random(); return new List<MyClass>() { new MyClass() {Name="Bob Zero",Value=(random.NextDouble() * 100.0)}, new MyClass() {Name="Bob One",Value=(random.NextDouble() * 100.0)}, new MyClass() {Name="Bob Two",Value=(random.NextDouble() * 100.0)}, new MyClass() {Name="Bob Three",Value=(random.NextDouble() * 100.0)} }; }

    Read the article

  • Rx framework: How to wait for an event to be triggered in silverlight test

    - by user324255
    Hi, I have a ViewModel that starts loading the Model async in the constructor, and triggers an event when the Model is loaded. I got a test working with the silverlight unit test framework, like this : bool done = false; [TestMethod] [Asynchronous] public void Test_NoCustomerSelected() { ProjectListViewModel viewModel = null; EnqueueCallback(() => viewModel = new ProjectListViewModel()); EnqueueCallback(() => viewModel.ModelLoaded += new EventHandler<EventArgs>(viewModel_ModelLoaded)); EnqueueConditional(() => done); EnqueueCallback(() => Assert.IsNotNull(viewModel.FilteredProjectList)); EnqueueCallback(() => Assert.AreEqual(4, viewModel.FilteredProjectList.Count)); EnqueueTestComplete(); } void viewModel_ModelLoaded(object sender, EventArgs e) { done = true; } But I'm beginning playing with Rx Framework, and trying to get my test to work, but so far I have no luck. Here's 2 attempts : public void Test_NoCustomerSelected2() { ProjectListViewModel viewModel = null; viewModel = new ProjectListViewModel(eventAggregatorMock.Object, moduleManagerMock.Object); IObservable<IEvent<EventArgs>> eventAsObservable = Observable.FromEvent<EventArgs>( ev => viewModel.ModelLoaded += ev, ev => viewModel.ModelLoaded -= ev); eventAsObservable.Subscribe(args => viewModel_ModelLoaded(args.Sender, args.EventArgs)); eventAsObservable.First(); Assert.IsNotNull(viewModel.Model); Assert.AreEqual(4, viewModel.Model.Count); } [TestMethod] public void Test_NoCustomerSelected3() { ProjectListViewModel viewModel = null; var o = Observable.Start(() => viewModel = new ProjectListViewModel(eventAggregatorMock.Object, moduleManagerMock.Object)); IObservable<IEvent<EventArgs>> eventAsObservable = Observable.FromEvent<EventArgs>( ev => viewModel.ModelLoaded += ev, ev => viewModel.ModelLoaded -= ev); o.TakeUntil(eventAsObservable) .First(); Assert.IsNotNull(viewModel.Model); Assert.AreEqual(4, viewModel.Model.Count); } The first test goes in waiting forever, the second doesn't work because the viewModel is null when it does the FromEvent. Anyone has a clue on how to do this properly?

    Read the article

  • Keeping the DI-container usage in the composition root in Silverlight and MVVM

    - by adrian hara
    It's not quite clear to me how I can design so I keep the reference to the DI-container in the composition root for a Silverlight + MVVM application. I have the following simple usage scenario: there's a main view (perhaps a list of items) and an action to open an edit view for one single item. So the main view has to create and show the edit view when the user takes the action (e.g. clicks some button). For this I have the following code: public interface IView { IViewModel ViewModel {get; set;} } Then, for each view that I need to be able to create I have an abstract factory, like so public interface ISomeViewFactory { IView CreateView(); } This factory is then declared a dependency of the "parent" view model, like so: public class SomeParentViewModel { public SomeParentViewModel(ISomeViewFactory viewFactory) { // store it } private void OnSomeUserAction() { IView view = viewFactory.CreateView(); dialogService.ShowDialog(view); } } So all is well until here, no DI-container in sight :). Now comes the implementation of ISomeViewFactory: public class SomeViewFactory : ISomeViewFactory { public IView CreateView() { IView view = new SomeView(); view.ViewModel = ???? } } The "????" part is my problem, because the view model for the view needs to be resolved from the DI-container so it gets its dependencies injected. What I don't know is how I can do this without having a dependency to the DI-container anywhere except the composition root. One possible solution would be to have either a dependency on the view model that gets injected into the factory, like so: public class SomeViewFactory : ISomeViewFactory { public SomeViewFactory(ISomeViewModel viewModel) { // store it } public IView CreateView() { IView view = new SomeView(); view.ViewModel = viewModel; } } While this works, it has the problem that since the whole object graph is wired up "statically" (i.e. the "parent" view model will get an instance of SomeViewFactory, which will get an instance of SomeViewModel, and these will live as long as the "parent" view model lives), the injected view model implementation is stateful and if the user opens the child view twice, the second time the view model will be the same instance and have the state from before. I guess I could work around this with an "Initialize" method or something similar, but it doesn't smell quite right. Another solution might be to wrap the DI-container and have the factories depend on the wrapper, but it'd still be a DI-container "in disguise" there :) Any thoughts on this are greatly appreciated. Also, please forgive any mistakes or rule-breaking, since this is my first post on stackoverflow :) Thanks! ps: my current solution is that the factories know about the DI-container, and it's only them and the composition root that have this dependency.

    Read the article

  • Silverlight 3 - Creating Custom Objects inside a Merged ResourceDictionary

    - by Tony Heupel
    I have custom classes that I currently instantiate within App.xaml as resources. I want to move these custom objects into a Merged ResourceDictionary, where they are used within styles, and keep them close to where they are used. Here's an example of what I want, arbitrarily using fake converter objects, but they could be any custom object... App.xaml (namespace declarations ommitted): <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Merged.xaml" /> </ResourceDictionary.MergedDictionaries> <Style x:Key="SomeStyle" TargetType="SomeControl"> ... </Style> ... </ResourceDictionary> And then in Merged.xaml (namespace declarations omitted): <ResourceDictionary> <cvt:VisibilityToBoolConverter x:Key="BoolToVisibility" Inverted="True"/> <cvt:VisibilityToBoolConverter x:Key="NotBoolToVisibility" Inverted="True" Not="True"/> <Style x:Key="SomethingThatUsesVisibilityToBoolConvertersStyle" TargetType="SomeOtherControl"> .... </Style> </ResourceDictionary> The issue I'm seeing is this: when I create the BoolToVisibility and NotBoolToVisibility objects (as well instantiating other objects that are instances of custom classes I have created) just as part Application.Resources, they are created and all the references work as expected; however, when I move these into a Merged Resource Dictionary (as I have in the sample above), I get a malformed Application exception when the Silverlight application loads. I belive this to be an issue with how objects are instantiated differently in Merged Resource Dictionaries (I belive it is more of a lazy-load approach), but I would expect it to work nonetheless. I am very much able to add Style objects, DataTemplates, ControlTemplates, and the like. But when I want to create instances of custom classes that are named or keyed using Xaml, it works great inside of App.xaml's Application.Resources directly and Application.Resources/ResourceDictionary as well. As soon as they are moved into a merged dictionary, it throws the exception. Is this by design? Any other ideas that work? Thanks in advance...

    Read the article

  • Silverlight DataGrid's sort by column doesn't update programmatically changed cells

    - by David Seiler
    For my first Silverlight app, I've written a program that sends user-supplied search strings to the Flickr REST API and displays the results in a DataGrid. Said grid is defined like so: <data:DataGrid x:Name="PhotoGrid" AutoGenerateColumns="False"> <data:DataGrid.Columns> <data:DataGridTextColumn Header="Photo Title" Binding="{Binding Title}" CanUserSort="True" CanUserReorder="True" CanUserResize="True" IsReadOnly="True" /> <data:DataGridTemplateColumn Header="Photo" SortMemberPath="ImageUrl"> <data:DataGridTemplateColumn.CellTemplate> <DataTemplate> <StackPanel Orientation="Horizontal" VerticalAlignment="Center"> <TextBlock Text="Click here to show image" MouseLeftButtonUp="ShowPhoto"/> <Image Visibility="Collapsed" MouseLeftButtonUp="HidePhoto"/> </StackPanel> </DataTemplate> </data:DataGridTemplateColumn.CellTemplate> </data:DataGridTemplateColumn> </data:DataGrid.Columns> </data:DataGrid> It's a simple two-column table. The first column contains the title of the photo, while the second contains the text 'Click here to show image'. Clicks there call ShowPhoto(), which updates the Image element's Source property with a BitmapImage derived from the URI of the Flickr photo, and sets the image's visibility to Visible. Clicking on the image thus revealed hides it again. All of this was easy to implement and works perfectly. But whenever I click on one of the column headers to sort by that column, the cells that I've updated in this way do not change. The rest of the DataGrid is resorted and updated appropriately, but those cells remain behind, detached from the rest of their row. This is very strange, and not at all what I want. What am I doing wrong? Should I be freshening the DataGrid somehow in response to the sort event, and if so how? Or if I'm not supposed to be messing with the contents of the grid directly, what's the right way to get the behavior I want?

    Read the article

  • Trouble using CollectionViewSource in Silverlight

    - by Johnny
    Hi, I having some trouble when implementing the CollectionViewSource in silverlight. I'm new in this topic, so basically I've been following what I find searching through the web. Here's what I've been trying to do so far. I'm creating a CollectionViewSource in the resources tag: <UserControl.Resources> <CollectionViewSource x:Key="TestCVS"> <CollectionViewSource.SortDescriptions> <scm:SortDescription PropertyName="Value" Direction="Ascending" /> </CollectionViewSource.SortDescriptions> </CollectionViewSource> </UserControl.Resources> Then I'm binding my TestCVS in a HierarchicalDataTemplate: <common:HierarchicalDataTemplate ItemsSource="{Binding Source={StaticResource TestCVS}}"> <common:HierarchicalDataTemplate.ItemTemplate> <common:HierarchicalDataTemplate> <Border BorderBrush="#FF464646" BorderThickness="1" CornerRadius="3" Padding="5"> <Grid> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <StackPanel Orientation="Horizontal" HorizontalAlignment="Left"> <TextBlock TextWrapping="Wrap" Text="{Binding MyClassField}"/> </StackPanel> </Grid> </Border> </common:HierarchicalDataTemplate> </common:HierarchicalDataTemplate.ItemTemplate> </common:HierarchicalDataTemplate> Now, in the code behind I'm assigning the Source for the TestCVS in a property, like this: private ObservableCollection<MyClass> _MyClass; public ObservableCollection<MyClass> MyClass { get { return _MyClass; } set { var testCVS = (this.Resources["TestCVS"] as CollectionViewSource); if (testCVS != null) testCVS.Source = value; } } After testing this I realize that the information is not showing on screen and I don't really know why, can anyone help me on this matter? Hope this makes any sense, thanks in advance!

    Read the article

  • XPathNavigator in Silverlight

    - by vladimir
    I have a code library that makes heavy use of XPathNavigator to parse some specific xml document. The xml document is cross-referenced, meaning that an element can reference another which has not yet been encountered during parsing: <ElementA ...> <DependentElementX id="1234"> </ElementA> <ElementX id="1234" .../> The document doesn't really look like this, but the point is that 1) there is an xml schema that enforces the overall document structure, 2) elements inside the document can reference each other using some IDs, and 3) there is quite a few such cross references between different elements in the document. The document is parsed in two phases. In the first pass I walk through the document XPathDocument doc = ...; XPathNavigator nav = doc.CreateNavigator(); nav.MoveToRoot(); nav.MoveToFirstChild()... and occasionally 'bookmark' the current position (element) in the document using XPathNavigator.Clone() method. This gives me a lightweight instance of an XPathNavigator which I can store somewhere and use later to jump back to a particular place (element) in my document. Once I have enough information collected in the first pass (for example, I have made sure there is indeed an ElementX with an id='1234'), I jump back to saved bookmarks (using those saved XPathNavigators) and complete the parsing. Well, now I'm about to use this library in Silverlight 3.0 and to my horror the XPathNavigator is not in the System.Xml assembly. Questions: 1) Am I missing something obvious (i.e. XPathNavigator does exist in some shape or form, for example in a toolkit or a freeware library)? 2) If I do have to make modifications in the code, what would be the best way to go? Ideally, I would like to make minimal changes, not to rewrite 80% of the code just to be able to use something like XLinq. To resume, in case I have to give up XPathNavigator, all I need is a way to bookmark places in my document and to get back to them so that I can continue to iterate from where I left off. Thanks in advance for any help/ideas.

    Read the article

  • How to implement code for multiple buttons using c++ in Silverlight for Windows Embedded

    - by Abhi
    Dear all I have referred the following link: Silverlight for Windows Embedded By referring this link i created a demo application which consist of two buttons created using Microsoft expression blend 2 tools. And then written a code referring the above site. Now my button names are "Browser Button" and "Media Button". On click of any one of the button i should able to launch the respective application. I was able to do for "Browser Button" but not for "Media Button" and if i do for "Media Button" then i am not able to do for "Browser Button".. I mean to say that how should i create event handler for both the buttons. This is the code in c++ which i should modify class BtnEventHandler { public: HRESULT OnClick(IXRDependencyObject* source,XRMouseButtonEventArgs* args) { RETAILMSG(1,(L"Browser event")); Execute(L"\\Windows\\iesample.exe",L""); return S_OK; } }; // entry point for the application. INT WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, LPWSTR lpCmdLine,int nCmdShow) { PrintMessage(); int exitCode = -1; HRESULT hr = S_OK; if (!XamlRuntimeInitialize()) return -1; HRESULT retcode; IXRApplicationPtr app; if (FAILED(retcode=GetXRApplicationInstance(&app))) return -1; if (FAILED(retcode=app->AddResourceModule(hInstance))) return -1; XRWindowCreateParams wp; ZeroMemory(&wp, sizeof(XRWindowCreateParams)); wp.Style = WS_OVERLAPPED; wp.pTitle = L"Bounce Test"; wp.Left = 0; wp.Top = 0; XRXamlSource xamlsrc; xamlsrc.SetResource(hInstance,TEXT("XAML"),MAKEINTRESOURCE(IDR_XAML1)); IXRVisualHostPtr vhost; if (FAILED(retcode=app->CreateHostFromXaml(&xamlsrc, &wp, &vhost))) return -1; IXRFrameworkElementPtr root; if (FAILED(retcode=vhost->GetRootElement(&root))) return -1; IXRButtonBasePtr btn; if (FAILED(retcode=root->FindName(TEXT("BrowserButton"), &btn))) return -1; IXRDelegate<XRMouseButtonEventArgs>* clickdelegate; BtnEventHandler handler; if(FAILED(retcode=CreateDelegate (&handler,&BtnEventHandler::OnClick,&clickdelegate))) return -1; if (FAILED(retcode=btn->AddClickEventHandler(clickdelegate))) return -1; UINT exitcode; if (FAILED(retcode=vhost->StartDialog(&exitcode))) return -1; return exitCode; } I have to add event handler for both the button so that on emulator whenever i click on any one of the button i should be able to launch the respective applications. Thanks in advance

    Read the article

< Previous Page | 56 57 58 59 60 61 62 63 64 65 66 67  | Next Page >