Windows 2012 Hosting - MVC 6 and SQL 2014 BLOG

Tutorial and Articles about Windows Hosting, SQL Hosting, MVC Hosting, and Silverlight Hosting

SilverLight Hosting - ASPHostPortal.com :: WCF RIA Services

clock August 22, 2016 19:39 by author Armend

RIA Services mainly targets Business Application Development, and comes across good for this purpose from a few different angles.

  • RIA Services simplifies the traditional n-tier application pattern by bringing together the ASP.NET and Silverlight platforms. If you have ever gone through the motions of creating a WCF Service, and then adding a service reference to your Silverlight project you will quickly find that the service calls are all asynchronous, and require you to specify an OnRequestCompleated method for calls that you make to that web service. While there are asynchronous programming patterns out there most business application developers prefer the tried and true N-Tier approach. Asynchronous Method calls make N-Tier Architecture difficult
  • As stated above Ria simplifies tiered architecture this means it is a great choice for creating applications using some of the more popular architectural patterns like MVVM, and MVC.
  • Because RIA Services is from Microsoft, you get tight Visual Studio Integration, and lots of Blogs, and Documentation covering it's use. While some of the open source projects out there are pretty good, most lake adequate documentation and have a steep learning curve.
  • Ria Services is flat out great for Rapid Application Development. There is Code Generation generation built into Visual Studio to generate Domain Services directly from ADO.NET Entities Models that your Silverlight applications can consume.

Where Can I Get WCF RIA Services

You can Get Wcf Ria Services From the Microsoft Web Platform Installer, located here.

  1. Highlight the Web Platform Tab
  2. Scroll Down to Tools
  3. Click the customize Tab
  4. and check off what you need

If you don't have Visual Studio go ahead and check off to get the Express Version. You obviously want to get the RIA Services Toolkit, and while you're here get the the Silverlight 4 Toolkit, and Tools for Visual Studio as well. After the install completes you will have everything you need to work with Silverlight 4 and RIA Services from within Visual Studio.

 

Options for Integrating WCF RIA Services into your Projects

There are a few different way out of the box to integrate WCF RIA Services into your projects using Visual Studio

  • Using the Silverlight Business Application Project Template
  • RIA Services in the Silverlight Application Project Template
  • Using the RIA Services Class Library Project Template

In this post we take a look at each of these approaches, talk about when and how they are useful, and show how implement each one. For this purpose I have created a Visual Studio Solution containing each implementation listed above
In the real world you are not likely to have a solution which implements any combination of these approaches, but for this example it is nice to have them all in one place to look at.

The Silverlight Business Application Project

If you are creating an application that requires Login, Registration, and User Authentication the Silverlight Business Application Project Template is a good way to go. It includes all this right out of the box. It also has website like layout and styles you can customize and some useful helper methods. You can actually learn a few things just by creating this project and then giving it a gook look over.

To create a Silverlight Business Application:

Right Click on your Solution and select "Add New Project", Select "Silverlight" from the Tree Menu on the Left, and then Select "Silverlight Business Application".
This will create a new two Projects in you solution automatically
You now have a Web Application Project to host your Silverlight Application and Domain Services, and The RIA Link between the two projects is all set up so you can begin adding and consuming WCF RIA Services. If you run the project now you will see all the out of the box features I mentioned are there.

  • Configurable Layout and Styles
  • Login
  • Registration

Not bad for right out of the box. I do have a couple of small issues with this though. Sure, it's great Microsoft has given us all this stuff without having to write a single line of code, but, I would have a couple things different if it were up to me.

  • 1. I wish the project template had a few config options upon creation. For example, for larger projects I may want all my services to be in a WCF RIA Services Class Library (RIA Class Library covered in detail below) in  instead of in the Web Application Project. Now I would have to move them.
  • 2. I'm not really sure what kind of Architectural Pattern they are trying to implement here. As you can see from the image of the Solution Explorer above there is a folder named "Models" in both the Web Application Project, and in the silverlight project. Then there is a Views folder in the Silverlight project that has views in it, but then no ViewModels or Controllers. Okay, so my point is what are they going for here? It makes me want to start moving the code around. If I'm not alone on this please leave me a comment. Anyway, small issues compared to the big picture.

WCF RIA Services Enabled Silverlight Application

If you don't need all the stuff that's included in the Silverlight Business Application above, or plan to just write them yourself, you can also enable RIA Services in a regular silverlight application.

To create a WCF RIA Services Enabled Silverlight Application:

Right Click on your Solution and select "Add New Project", Select "Silverlight" from the Tree Menu on the Left, and then Select "Silverlight Application".
When you click OK to add the new Silverlight Application a Dialog will appearer allowing you create a New Web Application to host your Silverlight Application in, or to host your Silverlight Application in an existing Web Project. Either way all you need to do is check the box to "Enable WCF RIA Services".
Then when your Project is created, it will already be set up to use RIA Services. You can now start adding domain services to your web project and the RIA link is in place and ready to go.

WCF RIA Services Class Library

The last option is the WCF RIA Services Class Library. In my experience the more separation you have in your solution the better. This project template allows you to house your Domain Services in separate assemblies.

To create a Solution that uses a WCF RIA Services Class Library:

Right Click on your Solution and select "Add New Project", Select "Silverlight" from the Tree Menu on the Left, and then Select "Silverlight Application".
When the project Dialog box appears allowing you to host your silverlight application in an existing or new Web Application, leave the "Enable WCF RIA Services" checkbox UN-CHECKED. The RIA Link will exist in the RIA Services Class Library.

Now right Click on your Solution and select "Add New Project", Select "Silverlight" from the Tree Menu on the Left, and then Select "WCF RIA Services Class Library".
This will actually create two projects. The RIA Services Class Library Consists of a Windows Class Library and a Silverlight Class Library and the two projects created contain the RIA Link. The project ending in .Web is the Windows Class Library and will run on the server while the other is the Silverlight Class Library will run on the client. Your solution should now look something like this.
All you need to do now is:

  • Add a reference to the Silverlight Class Library in your Silverlight Application
  • Add a reference to the Windows Class Library in your Web Application

And you are now set up and ready to start adding Domain Services to your server project for consumption in your Web Project. When using this set up you should add your domain services to you Windows Class Library section of your RIA Services Class Library.

Creating and Consuming Domain Services

Now that we know how to set up our RIA Services Project, Lets take a look at adding a Domain Service and consuming it in out Silverlight client to test that we have everything wired up correctly. In all of the scenarios listed above you will always add your Domain Service on the server side and consume that service on the Silverlight Client.
To show you how quick and easy it is to get a Domain Service up and running we are going to create a Domain Service form and ADO.NET Entities Data Model.

  • Start by Creating a Database. Mine consist of only one table with a very simple schema for this example.
  • Now right Click on your Web Project and select "Add New Item", Select "Data" from the Tree Menu on the Left, and then Select "ADO.NET Entity Data Model".
  • Highlight "Generate From Database" and click "Next".
  • Select your Target Database and click "Next".
  • Select the tables you want to generate the Model from and click "Finish".
  • Now that your Entities Data Model has been created do a Rebuild on the project before you do any thing else. This is important because if you forget to rebuild what will happen is when you go to create the Domain Service it will not be able to find your Entities. So go ahead and rebuild now and then we can create out first Domain Service.
  • Now right Click on your Web Project and select "Add New Item", Select "Web" from the Tree Menu on the Left, and then Select "Domain Service Class".
  • Click "Add" and you will get a Dialog Box Allowing you to generate your Domain Service from your entities. Select Enable Editing if you want it to Generate Update, Insert and Delete methods as well.
  • Now Click "OK" and it will generate your Domain Service class. It will look something like this.


[EnableClientAccess()]  
    public class ContactDomainService : LinqToEntitiesDomainService  
    {    

        // TODO:  
        // Consider constraining the results of your query method.  If you need additional input you can  
        // add parameters to this method or create additional query methods with different names.  
        // To support paging you will need to add ordering to the 'Contacts' query.  
        public IQueryable GetContacts()  
        {  
            return this.ObjectContext.Contacts;  
        }    

        public void InsertContact(Contact contact)  
        {  
            if ((contact.EntityState != EntityState.Detached))  
            {  
                this.ObjectContext.ObjectStateManager.ChangeObjectState(contact, EntityState.Added);  
            }  
            else 
            {  
                this.ObjectContext.Contacts.AddObject(contact);  
            }  
        }    

        public void UpdateContact(Contact currentContact)  
        {  
            this.ObjectContext.Contacts.AttachAsModified(currentContact, this.ChangeSet.GetOriginal(currentContact));  
        }    

        public void DeleteContact(Contact contact)  
        {  
            if ((contact.EntityState == EntityState.Detached))  
            {  
                this.ObjectContext.Contacts.Attach(contact);  
            }  
            this.ObjectContext.Contacts.DeleteObject(contact);  
        }  
    }

Notice it created services methods to preform all the CRUD opperations we need against our Database.
Now in our Silverlight project we will create a Grid in our MainPage.xaml to display our data like so:

<sdk:DataGrid x:Name="DataGrid" Margin="12" AutoGenerateColumns="True" />

Then in the code behind (MainPage.xaml.cs) we will add the code to call our domain service and populate our grid.

  • You will need to add a using directive to the Namespace in your server project where your domain services are located.
  • Create a private instance of your DomainContext
  • In the constructor call the load method of your context and pass in your GetContactsQuery from your Domain Service
  • Set the ItemSource Property of your DataGrid to the Collection of Contacts now available in your DataContext.

using SilverlightApplication3.Web;    
namespace SilverlightApplication3  
{  
    public partial class MainPage : UserControl  
    {  
        private ContactDomainContext _context = new ContactDomainContext(); 

        public MainPage()  
        {  
            InitializeComponent();  
            _context.Load(_context.GetContactsQuery());  
            DataGrid.ItemsSource = _context.Contacts;  
        }  
    }  
}

Now hit F5 and run the application. TADA! You should now see your data in the grid!
I hope this helped you in getting started with .NET RIA Services. I will be covering more in future posts.



SilverLight Hosting - ASPHostPortal.com :: How To clean up Broken SilverLight Installation

clock August 8, 2016 19:38 by author Armend

How To clean up Broken SilverLight Installation

In this article we will show you several tips to clean up broken silverlight after installation.  If Silverlight isn't working for you and you are getting errors trying to either uninstall, reinstall or upgrade Silverlight the steps below might help you. Note that I'm not listing all the steps to remove every trace of Silverlight from your machine. These steps are just meant to clean up enough so that future attempts to install, upgrade or uninstall don't fail.


Standard warnings about editing your registry apply. Be careful that you only delete what I say to delete below. If you delete too much by accident it is quite likely that you will break something and there is no way to undo accidental changes.

Steps to clean up a machine to fix a broken Silverlight installation:

  • In the Control Panel, open the Add/Remove Programs applet (Programs on Vista) and uninstall Microsoft Silverlight if it is shown as installed by clicking on it and then clicking Uninstall or Remove. If you get an error on this step (for example a dialog saying that the msi file cannot be found), just continue on to the next step
  • Using regedit, navigate to HKLM\Software\Microsoft\Silverlight and delete the key.
  • From an administrator command shell you can do this by running:

reg delete HKLM\Software\Microsoft\Silverlight /f

  • Using Windows Explorer, delete the “Microsoft Silverlight” directory from under Program Files.
  • From an administrator command shell on an x86 you can do this by running:

rmdir /s /q "%ProgramFiles%\Microsoft Silverlight
If you are on a 64-bit version of Windows, substitute ProgramFiles(x86):
rmdir /s /q "%ProgramFiles(x86)%\Microsoft Silverlight

ASPHostPortal.com

ASPHostPortal.com provides our customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest SilverLight hosting, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server 2008. We offers Windows hosting starts from $5/month only. We also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable Windows server 2008 Hosting, we should be your best choice.

 



Silverlight Hosting - ASPHostPortal :: What You Need to Know When Selecting a Grid

clock October 11, 2012 07:20 by author Jervis

Types of Grids

One of the most common misconceptions is the notion that a grid is a grid. In reality, there are several different types of grids and choosing the right one for your needs can help save substantial time and effort. Choosing the wrong grid can result in tremendous effort to make it work the way you need, which is quite frustrating. We will look at the different types of grids and the ways in which they are typically used.

Cell-oriented Grids

-
No assumptions on layout - Cell-oriented grids do not make any assumptions on the layout of data. They work very well when you wish to have complete control over the layout. They allow you to display data that flows over multiple cells and embed controls such as charts that occupy several underlying cells. You can mix different kinds of cells in the same column.

-
Excel-like behavior - Each cell is independent of other cells. Commonly, you're able to set 50 different attributes on each cell.

-
Formula support - Cell-oriented grids typically offer support for cell-level formulas, similar to Excel.

-
No assumptions on data source - Cell-oriented grids do not expect data to be in a certain format. They allow data to be provided on demand from any source. Binding to data usually involves the implementation of simple callbacks.

Data-bound Grid Controls

-
Homogenous columns - Data-bound grid controls assume that data in a column will be the same type. They work best when most of your data comes from a straight tabular data source and can be displayed in the same layout. They do not work well if you wish to have more control over the layout of your display.

-
Binding to standard types - Data-bound grid controls can be bound to any standard data source with a few lines of code.

-
Rich metadata - Data-bound grids utilize type metadata and other information available from data-binding interfaces. Operations such as sorting, filtering, and grouping are also easier to implement with data-bound grids because of this rich metadata.

-
Support for editing - Support for editing is implemented in most data-bound grid controls. If the backing data store supports editing, adding new rows, and deleting current rows, such support will automatically become available in data-bound grids.

-
Support for automatic updates - Data-bound grid controls can automatically display changes to the data source to which they are bound, provided the data source implements appropriate interfaces.

-
Business objects - Data-bound grid controls support displaying data in business objects, provided such data will support one of the commonly used .NET data-binding interfaces.

-
Delegating common operations to the server - It is typically desirable to delegate such operations to the server. This is the default behavior with most controls.

-
Support for expressions or formulas - Data-bound grid controls do not typically support cell-level formula calculations (like Excel). They instead offer unbound columns where simple expressions may be used to calculate the displayed value. If you need Excel-like formulas, then a cell-oriented grid is a better choice.

-
Displaying related data - Data-bound grids that support displaying related information display such data inline. This is referred to as a hierarchical display or nested table. It is possible for a hierarchical grid to support editing and differing levels in nested tables.

-
Displaying foreign key references - When you have a foreign key relationship, data-bound grid controls should easily display values from the related table.

-
Displaying grouped data - Grouping classifies a list of data based on one or more fields. Data-bound grids can support grouping, along with custom summaries and data updates with multiple field groupings.

Pivot Grids

Pivot grids are very powerful and allow for the display and analysis of massive amounts of data in a summarized, condensed format. Please be sure to test with at least five times the data you expect to work with (both rows and columns). Also, test with several grouping levels on both the row and column axes.

Tree Grids

Tree grids resemble tree controls, but instead of displaying just one column of information, as with a typical tree, they display additional attributes as additional columns. Test for editing and load-on-demand support.

 



WCF Hosting - ASPHostPortal :: Setting up a netTcpBinding enabled WCF Service in IIS 7

clock September 14, 2012 09:06 by author Jervis

netTcpBinding is a secure, reliable binding suitable for cross-machine communication. It uses TCP for message delivery along with a binary message encoding which makes is faster than HTTP based bindings such as WSHttpBinding and BasicHttpBinding.

Hosting a netTcpBinding service in IIS 7 is simple, however it requires several steps.


1. Add Non-HTTP Activation: from the Add Features Wizard select .NET Framework 3.0 Features and add Non-HTTP Activation




2. Make sure the Net.TCP services are running:
netTcpBinding uses two windows services. NetTcpActivator - Receives activation requests over the net.tcp protocol and passes them to the Windows Process Activation Service and NetTcpPortSharing - provides ability to share TCP ports over the net.tcp protocol. This service enables net.tcp ports to be shared across multiple user processes which will make it easier to manage open ports in your network.



3. In IIS navigate to your website and select Advanced Settings from the right menu. Add net.tcp to the Enabled Protocols.




4. In IIS select Bindings from the right menu. Add a new net.tcp binding with the port you wish to use. I used port 808 so my Binding information looks like 808:*






5. From now on the system is ready to run netTcpBinding so you can now add it to web.config:


<system.serviceModel>
      <services>
            <service behaviorConfiguration="MyBehavior"
            name="MyNamespace.MyService">
            <endpoint address=""
                          binding="netTcpBinding"
                          bindingConfiguration="portSharingBinding"
                          name="MyServiceEndpoint"
                          contract="MyNamespace.IMyService">
                  <identity>
                        <dns value="localhost" />
                  </identity>
            </endpoint>
 
            <endpoint address="mex"
                          binding="mexTcpBinding"
                          bindingConfiguration=""
                          name="MyServiceMexTcpBidingEndpoint"
                          contract="IMetadataExchange" />
                  <host>
                        <baseAddresses>
                              <add baseAddress="net.tcp://MyServerIPAddress:808/MyService.svc" />
                        </baseAddresses>
                  </host>
            </service>
      </services>
      <behaviors>
        <serviceBehaviors>
            <behavior name="MyBehavior">
              <serviceMetadata httpGetEnabled="false" />
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>
      </behaviors>
      <bindings>
            <netTcpBinding>
                  <binding name="portSharingBinding" portSharingEnabled="true"/>
            </netTcpBinding>
      </bindings>
</system.serviceModel>


A mexTcpBinding endpoint is needed in order to use IMetadataExchange over TCP. IMetadataExchange exposes methods used to return metadata about a service. Now the service should be up and running so from Visual Studio just add a Service reference. Point the reference to:
net.tcp://MyServerIPAddress:808/MyService.svc. It should generate the following configuration

<system.serviceModel>
          <bindings>
                    <netTcpBinding>
                             <binding name="MyServiceEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536">
                                      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                                      <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
                                      <security mode="Transport">
                                               <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                                               <message clientCredentialType="Windows" />
                                      </security>
                             </binding>
                    </netTcpBinding>
          </bindings>
          <client>
                    <endpoint address="net.tcp://MyServerName/MyService.svc" binding="netTcpBinding" bindingConfiguration="MyServiceEndpoint" contract="MyNamespace.IMyService" name="MyServiceEndpoint">
                              <identity>
                                        <dns value="localhost" />
                              </identity>
                    </endpoint>
          </client>
</system.serviceModel>


Now you are ready to use the service from the client you generated:


using (MyServiceClient client = new MyServiceClient())
{
        client.Open();
        client.MyMethod();
        client.Close();
}


That’s it. You should be able to communicate with your service faster and more efficiently than any HTTP based binding

 



Silverlight 4 Hosting - ASPHostPortal :: Unhandled Error in Silverlight Application Code: 2104

clock November 16, 2010 06:59 by author Jervis

ERROR:



Solution:

When you add a Silverlight project to a solution, Visual Studio will ask you if you would like to create new web site to host it, or choose an existing one in your solution.  I choose an existing one.  By default, Visual Studio creates this in your HTML markup to host a Silverlight application:

    <div id="silverlight">

        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2">
               
          <param name="source" value="ClientBin/MySilverlightApp.xap"/>
          <param name="onError" value="onSilverlightError" />
          <param name="background" value="white" />
          <param name="minRuntimeVersion" value="3.0.40624.0" />
          <param name="autoUpgrade" value="true" />
          <param name="initParams" value="page=UserRegistrationView" />

          <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration:none">
               <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/>
          </a>         

        </object>       

        <iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe>
    </div>

Visual Studio does not account for the URL rewriting that comes with MVC and by default the path to xap file is wrong.  Change the source parameter to be rooted like so:

          <param name="source" value="/ClientBin/MySilverlightApp.xap"/>

Hope this help to solve your problem. J


Reasons why you must trust ASPHostPortal.com

Every provider will tell you how they treat their support, uptime, expertise, guarantees, etc., are. Take a close look. What they’re really offering you is nothing close to what ASPHostPortal does. You will be treated with respect and provided the courtesy and service you would expect from a world-class web hosting business.

You’ll have highly trained, skilled professional technical support people ready, willing, and wanting to help you 24 hours a day. Your web hosting account servers are monitored from three monitoring points, with two alert points, every minute, 24 hours a day, 7 days a week, 365 days a year. The followings are the list of other added- benefits you can find when hosting with us:

- DELL Hardware
Dell hardware is engineered to keep critical enterprise applications running around the clock with clustered solutions fully tested and certified by Dell and other leading operating system and application providers.
- Recovery Systems
Recovery becomes easy and seamless with our fully managed backup services. We monitor your server to ensure your data is properly backed up and recoverable so when the time comes, you can easily repair or recover your data.
- Control Panel
We provide one of the most comprehensive customer control panels available. Providing maximum control and ease of use, our Control Panel serves as the central management point for your ASPHostPortal account. You’ll use a flexible, powerful hosting control panel that will give you direct control over your web hosting account. Our control panel and systems configuration is fully automated and this means your settings are configured automatically and instantly.
- Excellent Expertise in Technology
The reason we can provide you with a great amount of power, flexibility, and simplicity at such a discounted price is due to incredible efficiencies within our business. We have not just been providing hosting for many clients for years, we have also been researching, developing, and innovating every aspect of our operations, systems, procedures, strategy, management, and teams. Our operations are based on a continual improvement program where we review thousands of systems, operational and management metrics in real-time, to fine-tune every aspect of our operation and activities. We continually train and retrain all people in our teams. We provide all people in our teams with the time, space, and inspiration to research, understand, and explore the Internet in search of greater knowledge. We do this while providing you with the best hosting services for the lowest possible price.
- Data Center
ASPHostPortal modular Tier-3 data center was specifically designed to be a world-class web hosting facility totally dedicated to uncompromised performance and security
- Monitoring Services
From the moment your server is connected to our network it is monitored for connectivity, disk, memory and CPU utilization – as well as hardware failures. Our engineers are alerted to potential issues before they become critical.
- Network
ASPHostPortal has architected its network like no other hosting company. Every facet of our network infrastructure scales to gigabit speeds with no single point of failure.
- Security
Network security and the security of your server are ASPHostPortal’s top priorities. Our security team is constantly monitoring the entire network for unusual or suspicious behavior so that when it is detected we can address the issue before our network or your server is affected.
- Support Services
Engineers staff our data center 24 hours a day, 7 days a week, 365 days a year to manage the network infrastructure and oversee top-of-the-line servers that host our clients’ critical sites and services.



Silverlight 4 Hosting - ASPHostPortal :: Filtering CollectionView Data in Silverlight 4

clock November 15, 2010 07:37 by author Jervis

If you are using Silverlight's ListBox control, you can filter the data in a CollectionViewSource object using just a little bit of simple code. For this example, I will be using a simple Product class with two properties, and a list of Product objects using the Generic List class. Try this out by creating a Product class as shown in the following code:

public class Product {
  public Product(int id, string name) {
    ProductId = id;
    ProductName = name;
  }

  public int ProductId { get; set; }
  public string ProductName { get; set; }
}

Create a collection class that initializes a property called DataCollection with some sample data as shown in the code below:

public class Products : List<Product>
{
  public Products()
  {
    InitCollection();
  }

  public List<Product> DataCollection { get; set; }

  List<Product> InitCollection()
  {
    DataCollection = new List<Product>();

  DataCollection.Add(new Product(1, "PDSA Framework"));
  DataCollection.Add(new Product(2, "Haystack"));
  DataCollection.Add(new Product(3, "Fundamentals of .NET eBook"));
  DataCollection.Add(new Product(4, "WPF Fundamentals Video"));
  DataCollection.Add(new Product(5, "Fundamentals of ASP.NET Security eBook"));
  DataCollection.Add(new Product(6, "Fundamentals of SQL Server eBook"));
  DataCollection.Add(new Product(7, "Microsoft VS.NET 2010"));
  DataCollection.Add(new Product(8, "Microsoft Silverlight 4"));

    return DataCollection;
  }
}

The screen shot shown in Figure 1 is a Silverlight page that allows the user to filter the Product data by typing in a value into the text box, then clicking on the Search button.



If the user fills in a partial product name, such as the letter 'F' and then clicks on the Search button, the results are as shown in Figure 2.



You next need to add an XML namespace to your MainPage.xaml so you can reference the Products class.

xmlns:local="clr-namespace:SLFilterData"

The 'local' namespace is the name of the project that you created (in my case 'SLFilterData'). Create a UserControl.Resources section in your Silverlight page that looks like the following:

<UserControl.Resources>
  <local:Products x:Key="products" />
  <CollectionViewSource x:Key="prodCollection"
                        Source="{Binding Source={StaticResource products},
                             Path=DataCollection}">
  </CollectionViewSource>
</UserControl.Resources>

The first line of code in the resources section creates an instance of your Products class. The constructor of the Products class calls the InitCollection method which creates the various Product objects and adds them to the DataCollection property of the Products class. Once the Products object is instantiated you now add a CollectionViewSource object in XAML using the Products object as the source of the data to this collection. A CollectionViewSource allows us to perform sorting, grouping and filtering on our collection of Product objects.

Next, you create the search area using a StackPanel, TextBlock, TextBox and a Button control:

<StackPanel Orientation="Horizontal"
            Margin="10"
            Grid.Row="0">
  <TextBlock Text="Enter Partial Name: " />
  <TextBox Width="100"
            Name="txtName" />
  <Button Name="btnSearch"
          Content="Search"
          Click="btnSearch_Click" />
</StackPanel>

Now add a list box to your XAML page and set the DisplayMemberProperty to be "ProductName" which is the property on the Product class that you wish to display in the list box.

<ListBox Margin="10"
          Grid.Row="1"
          Name="lstData"
          DisplayMemberPath="ProductName"
          ItemsSource="{Binding Source={StaticResource collProducts}}" />

Now you can write the code behind for the click event of the Seach button. In the Click event call a method name FilterData that will perform the filtering using CollectionViewSource.

private void FilterData()
{
  if (lstData != null)
  {
    ICollectionView dataView = default(ICollectionView);

    dataView = (ICollectionView)lstData.ItemsSource;

    dataView.Filter = prod => ((Product)prod).ProductName.ToLower()
                                 .StartsWith(txtName.Text.ToLower());

    lstData.ItemsSource = dataView;
  }
}

In the FilterData method you create an ICollectView object from the existing ItemsSource property of the list box. When you use a CollectionViewSource object in your XAML, the data is put in the collection as an object that implements the ICollectionView interface. You can then set the Filter property of the collection view to a predicate that will determine the filter on the data. After this is set, you give this new ICollectionView object to the ItemsSource property of the list box and the filter is applied. The new data is then displayed in the list box.

Summary

That's all there is to it. A simple way to allow your users to filter data from a collection with just a few lines of code!

Reasons why you must trust ASPHostPortal.com

Every provider will tell you how they treat their support, uptime, expertise, guarantees, etc., are. Take a close look. What they’re really offering you is nothing close to what ASPHostPortal does. You will be treated with respect and provided the courtesy and service you would expect from a world-class web hosting business.

You’ll have highly trained, skilled professional technical support people ready, willing, and wanting to help you 24 hours a day. Your web hosting account servers are monitored from three monitoring points, with two alert points, every minute, 24 hours a day, 7 days a week, 365 days a year. The followings are the list of other added- benefits you can find when hosting with us:

- DELL Hardware
Dell hardware is engineered to keep critical enterprise applications running around the clock with clustered solutions fully tested and certified by Dell and other leading operating system and application providers.
- Recovery Systems
Recovery becomes easy and seamless with our fully managed backup services. We monitor your server to ensure your data is properly backed up and recoverable so when the time comes, you can easily repair or recover your data.
- Control Panel
We provide one of the most comprehensive customer control panels available. Providing maximum control and ease of use, our Control Panel serves as the central management point for your ASPHostPortal account. You’ll use a flexible, powerful hosting control panel that will give you direct control over your web hosting account. Our control panel and systems configuration is fully automated and this means your settings are configured automatically and instantly.
- Excellent Expertise in Technology
The reason we can provide you with a great amount of power, flexibility, and simplicity at such a discounted price is due to incredible efficiencies within our business. We have not just been providing hosting for many clients for years, we have also been researching, developing, and innovating every aspect of our operations, systems, procedures, strategy, management, and teams. Our operations are based on a continual improvement program where we review thousands of systems, operational and management metrics in real-time, to fine-tune every aspect of our operation and activities. We continually train and retrain all people in our teams. We provide all people in our teams with the time, space, and inspiration to research, understand, and explore the Internet in search of greater knowledge. We do this while providing you with the best hosting services for the lowest possible price.
- Data Center
ASPHostPortal modular Tier-3 data center was specifically designed to be a world-class web hosting facility totally dedicated to uncompromised performance and security
- Monitoring Services
From the moment your server is connected to our network it is monitored for connectivity, disk, memory and CPU utilization – as well as hardware failures. Our engineers are alerted to potential issues before they become critical.
- Network
ASPHostPortal has architected its network like no other hosting company. Every facet of our network infrastructure scales to gigabit speeds with no single point of failure.
- Security
Network security and the security of your server are ASPHostPortal’s top priorities. Our security team is constantly monitoring the entire network for unusual or suspicious behavior so that when it is detected we can address the issue before our network or your server is affected.
- Support Services
Engineers staff our data center 24 hours a day, 7 days a week, 365 days a year to manage the network infrastructure and oversee top-of-the-line servers that host our clients’ critical sites and services.



Silverlight 4 Hosting - ASPHostPortal :: Deploying a Silverlight 4 Application Connected to a Database

clock November 9, 2010 09:08 by author Jervis

This article shows how to deploy a Silverlight application 4 connected to a database. We are going to use IIS 7.5 to do it.

This is the error message:

"System.ServiceModel.DomainServices.Client.DomainOperationException: Load operation failed fore query 'GetProducts'.... Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed"

And I assume that you have finished your Silverlight app using VS 2010 and .NET Framework 4.0. We have a few views and an MDF database in our App_Data folder. It would look like this:



Now, we are going to deploy our application. You can see this figure below:



This will open up a dialog window. We can create publishing templates. Let’s just choose the location where we are going to publish our application (our computer, a web server, FTP…). I like to check the “delete existing files in the destination folder before publishing” option. Click the Publish button.

Now we are ready to work with the IIS configuration (I'm using Windows 7).

Let’s open the Windows Start Menu, and type “inetmgr” in the search box. The IIS Manager Window will show up.

Go to the MIME Types.



In the appearing list, we’ll need to include the following types (XAML, XAP, XBAP) as shown in the image below:



Now, in the left menu, let’s go to Sites, and let’s add our Web Site (as default site, virtual directory… based on our own needs). When done, let’s click in our application, like this:



In the menu that appears on the right side, we’ll click the “Advance Configuration” link. Now, in the dialog, we’ll click in “Application Group”, and you’ll notice that a button with three dots will appear on its right. Click that button and you will see another dialog. Select ASP.NET v4.0, as shown in the image below:




If ASP.NET v4.0 is not selected, and you leave
DefaultAppPool as I did in the beginning, you will get the following error message every time your application tries to connect with the database: “There is an error in the service with the Get function..”


So, now that we selected our Application Group, let us configure it. In the left panel (back in the IIS Manager Window), right above our Default Site, we’ll see “Application Groups”. Click it. A list will appear in the center panel. Let’s open the ASP.NET v4.0 and select the right framework version. Click ok and select it again, but instead of opening it, this time we’ll go to the right panel, and we’ll click on “Advance Configuration”:



Change the Local System and select Network Service, as shown in the image above. And that’s it! Now we are able to access our data from our Silverlight 4 application without getting any error from the Web Server.

Hope this post can help!!

Reasons why you must trust ASPHostPortal.com

Every provider will tell you how they treat their support, uptime, expertise, guarantees, etc., are. Take a close look. What they’re really offering you is nothing close to what ASPHostPortal does. You will be treated with respect and provided the courtesy and service you would expect from a world-class web hosting business.

You’ll have highly trained, skilled professional technical support people ready, willing, and wanting to help you 24 hours a day. Your web hosting account servers are monitored from three monitoring points, with two alert points, every minute, 24 hours a day, 7 days a week, 365 days a year. The followings are the list of other added- benefits you can find when hosting with us:

- DELL Hardware
Dell hardware is engineered to keep critical enterprise applications running around the clock with clustered solutions fully tested and certified by Dell and other leading operating system and application providers.
- Recovery Systems
Recovery becomes easy and seamless with our fully managed backup services. We monitor your server to ensure your data is properly backed up and recoverable so when the time comes, you can easily repair or recover your data.
- Control Panel
We provide one of the most comprehensive customer control panels available. Providing maximum control and ease of use, our Control Panel serves as the central management point for your ASPHostPortal account. You’ll use a flexible, powerful hosting control panel that will give you direct control over your web hosting account. Our control panel and systems configuration is fully automated and this means your settings are configured automatically and instantly.
- Excellent Expertise in Technology
The reason we can provide you with a great amount of power, flexibility, and simplicity at such a discounted price is due to incredible efficiencies within our business. We have not just been providing hosting for many clients for years, we have also been researching, developing, and innovating every aspect of our operations, systems, procedures, strategy, management, and teams. Our operations are based on a continual improvement program where we review thousands of systems, operational and management metrics in real-time, to fine-tune every aspect of our operation and activities. We continually train and retrain all people in our teams. We provide all people in our teams with the time, space, and inspiration to research, understand, and explore the Internet in search of greater knowledge. We do this while providing you with the best hosting services for the lowest possible price.
- Data Center
ASPHostPortal modular Tier-3 data center was specifically designed to be a world-class web hosting facility totally dedicated to uncompromised performance and security
- Monitoring Services
From the moment your server is connected to our network it is monitored for connectivity, disk, memory and CPU utilization – as well as hardware failures. Our engineers are alerted to potential issues before they become critical.
- Network
ASPHostPortal has architected its network like no other hosting company. Every facet of our network infrastructure scales to gigabit speeds with no single point of failure.
- Security
Network security and the security of your server are ASPHostPortal’s top priorities. Our security team is constantly monitoring the entire network for unusual or suspicious behavior so that when it is detected we can address the issue before our network or your server is affected.
- Support Services
Engineers staff our data center 24 hours a day, 7 days a week, 365 days a year to manage the network infrastructure and oversee top-of-the-line servers that host our clients’ critical sites and services.



Silverlight 4 Hosting - ASPHostPortal :: Error Message – Load Operation Failed for query “GetUser”

clock November 9, 2010 04:54 by author Jervis

Sometimes we get this error when running WCF RIA Services.

“Load Operation Failed for query “GetUser”
.

This is always an annoying issue with Silverlight deployment to do with connection strings and domain authorizations. Basically it’s a very generic error that pops up if you’re using the in-built standard asp.net model, such as the RIA services models of .net/silverlight development using aspnet authorization and registration.


Why it can happens?

1. Your development system is using a local SQL Express database which works fine when your on your own machine, but once its online, it’s still trying to find the same LocalSqlServer or localhost, and obviously cant. You can get round this in your web.config, using stuff like:
     <remove />    <add connectionString=”etc etc”.>

2. Or possibly you have all the connection strings point to the right places, but your new server database doesnt contain all the necessary aspnet tables/framework. Theres some tools that are located in your windows/.net folders, such as aspnet_regiis.exe, which if you search for online, you willl get details on how to use them to automatically configure/update an sqlserver with the all the necessary aspnet objects.

3. You haven not deployed necessary references to the webserver, especially ones such as the System.Web.Ria, System.Web.DomainServices and System.ComponentModel.DataAnnotations. You can select them in your visual studio project and mark the Copy Local propery to True.

4. Also if you have any services mapped from server to client, such as WCF Services, make sure when your publishing to update their bindings/endpoint addresses in the client, as they will be still looking for those services on the localhost development server.

5. Also make sure you use a valid crossdomain.xml and clientaccesspolicy.xml on your web project/deployment. If you do a websearch for these two filenames, you will get lots of examples of various settings to use that might be relevant to your site operation
.

And, you have to check your IIS settings that sometimes cause the issue, like allowed IIS authentications (anonymous, impersonation, forms, etc).

The other alternative that you can consider is you can use mix of setting of the correct IIS authentication allowing anonymous and forms, and making sure the default connection strings were update correctly. As for the stuff on our server, please (if possible) remove ASP.NET authorization from your application and please write your own custom authorization, so it’s not even trying to update the local sql server for the inbuilt ASP.NET stuff
.

Hope this post can help you.

Reasons why you must trust ASPHostPortal.com


Every provider will tell you how they treat their support, uptime, expertise, guarantees, etc., are. Take a close look. What they’re really offering you is nothing close to what ASPHostPortal does. You will be treated with respect and provided the courtesy and service you would expect from a world-class web hosting business.

You’ll have highly trained, skilled professional technical support people ready, willing, and wanting to help you 24 hours a day. Your web hosting account servers are monitored from three monitoring points, with two alert points, every minute, 24 hours a day, 7 days a week, 365 days a year. The followings are the list of other added- benefits you can find when hosting with us:

- DELL Hardware
Dell hardware is engineered to keep critical enterprise applications running around the clock with clustered solutions fully tested and certified by Dell and other leading operating system and application providers.
- Recovery Systems
Recovery becomes easy and seamless with our fully managed backup services. We monitor your server to ensure your data is properly backed up and recoverable so when the time comes, you can easily repair or recover your data.
- Control Panel
We provide one of the most comprehensive customer control panels available. Providing maximum control and ease of use, our Control Panel serves as the central management point for your ASPHostPortal account. You’ll use a flexible, powerful hosting control panel that will give you direct control over your web hosting account. Our control panel and systems configuration is fully automated and this means your settings are configured automatically and instantly.
- Excellent Expertise in Technology
The reason we can provide you with a great amount of power, flexibility, and simplicity at such a discounted price is due to incredible efficiencies within our business. We have not just been providing hosting for many clients for years, we have also been researching, developing, and innovating every aspect of our operations, systems, procedures, strategy, management, and teams. Our operations are based on a continual improvement program where we review thousands of systems, operational and management metrics in real-time, to fine-tune every aspect of our operation and activities. We continually train and retrain all people in our teams. We provide all people in our teams with the time, space, and inspiration to research, understand, and explore the Internet in search of greater knowledge. We do this while providing you with the best hosting services for the lowest possible price.
- Data Center
ASPHostPortal modular Tier-3 data center was specifically designed to be a world-class web hosting facility totally dedicated to uncompromised performance and security
- Monitoring Services
From the moment your server is connected to our network it is monitored for connectivity, disk, memory and CPU utilization – as well as hardware failures. Our engineers are alerted to potential issues before they become critical.
- Network
ASPHostPortal has architected its network like no other hosting company. Every facet of our network infrastructure scales to gigabit speeds with no single point of failure.
- Security
Network security and the security of your server are ASPHostPortal’s top priorities. Our security team is constantly monitoring the entire network for unusual or suspicious behavior so that when it is detected we can address the issue before our network or your server is affected.
- Support Services
Engineers staff our data center 24 hours a day, 7 days a week, 365 days a year to manage the network infrastructure and oversee top-of-the-line servers that host our clients’ critical sites and services.



Silverlight 4 Hosting - ASPHostPortal :: New Features in Silverlight 4

clock November 4, 2010 08:05 by author Jervis

This is the new features in Silverlight 4:

1. Webcam and microphone access to allow sharing of video and audio for instance for chat or customer service applications.
2. Audio and video local recording capabilities capture RAW video without requiring server interaction, enabling a wide range of end-user interaction and communication scenarios for example video conferencing.
3. Bring data in to your application with features such as copy and paste or drag and drop.
4. Support conventional desktop interaction models through new features such as right-click context menu.
5. Multicast networking, enabling Enterprises to lower the cost of streaming broadcast events such as company meetings and training, interoperating seamlessly with existing Windows Media Server streaming infrastructure.
6. Read and write files to the user’s MyDocuments, MyMusic, MyPictures and MyVideos folder (or equivalent for non-windows platforms) for example storage of media files and taking local copies of reports.
7. Run other desktop programs such as Office, for example requesting Outlook to send an email, send a report to Word or data to Excel.
8. COM automation enables access to devices and other system capabilities by calling into application components; for instance to access a USB security card reader.
9. Comprehensive printing support enabling hardcopy reports and documents as well as a virtual print view, independent of screen content.
10. The .NET Common Runtime (CLR) now enables the same compiled code to be run on the desktop and Silverlight without change.

Now, you can get all the features with very low cost, only at ASPHostPortal.com. Please visit
http://www.asphostportal.com for more information.



Silverlight 4 Hosting - ASPHostPortal :: How to Command Control in Silverlight 4

clock November 3, 2010 07:47 by author Jervis

In this article we will take this proof of concept and demonstrate how through the use of commanding and binding we can virtually eliminate all code behind and implement to a strong MVVM architectural pattern.

Getting Started

I think few would argue with the value of a strong separation of concerns within the design of an application.  Over the last year the MVVM pattern has gained popularity in the Silverlight development community.  One of the challenges that developers faced in previous versions of the framework was the lack of commanding support in Silverlight.  Without commanding many developers had to write there own attached properties, or worse  yet, resort to event handling in their code behind, just to deal with responding to a button being clicked.  Today both the button and HyperlinkButton support commanding.

Model-View-ViewModel

Even though our sample application will only be a single page, we will still implement the MVVM pattern to eliminate any code in code behind of our MainPage.xaml.  MVVM requires that for every View we have a corresponding ModelView (MV) class.  Our View will set its DataContext equal to this class and bind all of the views data through public properties.


using System;
using System.IO;
using System.IO.IsolatedStorage;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;


using System.ComponentModel;

namespace VideoCaptureExample
{
    public class MainPageViewModel : INotifyPropertyChanged
    {
    . . . . .
    }
}


In our mainPage.xaml we will initialize our ViewModel class and set our LayoutRoot DataContext to this resource.  If our ViewModel required additional context or possibly aservices be injected into its constructor I would opts to use a ViewModel locator that has been stored as a ApplicationResource.

<UserControl x:Class="VideoCaptureExample.MainPage"
    . . . .
    d:DesignHeight="360" d:DesignWidth="610">
    <UserControl.Resources>
        <local:MainPageViewModel x:Key="MainViewModel"/>
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot" Background="White"         DataContext="{Binding Source={StaticResource MainViewModel}}">
    . . . . . .
    </Grid>
</UserControl
>

SaveCommand


One of the great advantages to commanding is encapsulation.  When an application has a function like “Save” its very likely that more then one action can trigger this behavior.  In our example we intend to allow the save to be triggered from a button, right click context menu as well a something being dragged to a specific location on the screen.  Creating a command has two parts.  First we need to write a class that implements the ICommand interface and second expose it through our view model..  The following is the general format of such a class.  When I create commands in Silverlight I like to inject my ViewModel in the event I need to check the state of my view before executing the command

using System;
using System.IO;
using System.IO.IsolatedStorage;
using System.Windows.Input;


namespace VideoCaptureExample
{
    public class SaveCommand : ICommand
    {
        private MainPageViewModel _viewModel;

        public SaveCommand(MainPageViewModel viewModel)
        {
            _viewModel = viewModel;
        }


        public event EventHandler CanExecuteChanged;
        public bool CanExecute(object parameter)
        {
            return (_viewModel.SelectedCapture != null) ? true : false;
        }


        public void Execute(object parameter)
        {
            Capture capture = parameter as Capture;
            if (capture != null)
            {
             . . . . .
            }
        }


        protected virtual void OnCanExecuteChanged(EventArgs e)
        {
            var canExecuteChanged = CanExecuteChanged;

            if (canExecuteChanged != null)
                canExecuteChanged(this, e);
        }


        public void RaiseCanExecuteChanged()
        {
            OnCanExecuteChanged(EventArgs.Empty);
        }
    }
}


In the above snippet there are three requirements when implementing the ICommand interface.  First we need to define a function called CanExecute.  This will be called to determine if a buttons enabled state is set to true or false.  What is great about CanExecute is that it eliminates custom business logic to determine if a command can be fired.  The second is an Execute method that is called when the user clicks a button referenced by the command.  All of my “Save” logic will be placed inside of this method.  A argument is passed to this method that allows data to be injected into the call. Setting CommandParameter on a Button will define what gets passed during the execute. The last requirement is the CanExecuteChanged event.  We can fire this event anytime we want buttons that are bound to this command to re-evaluate there enabled state.

To implement this command in our ViewModel, we need to expose the class as a property.

private SaveCommand _saveCommand;
public SaveCommand Save
{
    get
    {
        if (_saveCommand == null)
            _saveCommand = new SaveCommand(this);
        return _saveCommand;
    }
}


Once exposed, we can reference the SaveCommand through simple binding applied to the Button’s Command property and CommandParameter.  Now each time that a user clicks the “Save” button our command will be fired.

<Button x:Name="saveBtn" Content="Save"
    Width="70" Height="22" Margin="10,0,0,0"
    HorizontalAlignment="Right" VerticalAlignment="Center"
    Command="{Binding Save}"
    CommandParameter="{Binding ElementName=listImages, Path=SelectedItem}"/>


DelegateCommand

More often than not our command is not needed outside of the context of a single view.  If this is the case, we can delegate the implementation of the CanExecute and Execute to the ViewModel.  Lets say for example you have a command like “StartCapture” that is only appropriate for a single View.  In this scenario its a lot easier to have the business logic directly in the ViewModel than in a separate class. 

Using the same ICommand interface, we can create a reusable class that delegates both of these methods.  The following is the most popular approach.

using System;
using System.Windows.Input;

namespace VideoCaptureExample
{
    public class DelegateCommand : ICommand
    {
        private Predicate<object> _canExecute;
        private Action<object> _method;
        public event EventHandler CanExecuteChanged;

        public DelegateCommand(Action<object> method)
            : this(method, null)
        {
        }

        public DelegateCommand(Action<object> method, Predicate<object> canExecute)
        {
            _method = method;
            _canExecute = canExecute;
        }

        public bool CanExecute(object parameter)
        {
            if (_canExecute == null)
            {
                return true;
            }

            return _canExecute(parameter);
        }

        public void Execute(object parameter)
        {
            _method.Invoke(parameter);
        }


        protected virtual void OnCanExecuteChanged(EventArgs e)
        {
            var canExecuteChanged = CanExecuteChanged;

            if (canExecuteChanged != null)
                canExecuteChanged(this, e);
        }


        public void RaiseCanExecuteChanged()
        {
            OnCanExecuteChanged(EventArgs.Empty);
        }
    }
}

To implement this DelegateCommand class we do the following in our ViewModel.  Notice how our constructor gets passed two delegates, one for  CanExecute and one for Execute.  Calling this command from XAML is identical to our SaveCommand class.

private DelegateCommand _captureCommand;
public DelegateCommand Capture
{
    get
    {
        if (_captureCommand == null)
            _captureCommand = new DelegateCommand(OnCapture, CaptureCanExecute);

        return _captureCommand;
    }
}
. . . .
private void OnCapture(object parameter)
{
    UIElement element = parameter as UIElement;
    if (this.CaptureSource != null)
    {
    . . . .
    }
}
. . . .
private bool CaptureCanExecute(object parameter)
{
    return (_isCapturingVideo) ? true : false;
}

Using Binding to Avoid Commanding

One of the things that I think a lot developers forget is that TwoWay binding can be a great way to avoid having to create a command or event handler to respond to a user click.  Commands are great, but if you don’t need them don’t use them.

When all you want to do is take some action when a user clicks on an item in a list its very easy to allow a change in the lists SelectedItem to notify other controls.  Take for example the list of EffectShader displayed in the image below.  When a user clicks on any of the shaders, I want to apply that effect to my rectangle which is displaying my VideoBrush.  I can do this entirely using binding applied to both elements.

If we examine the code below, you will see a bunch of bindings.  First, our ListBox.ItemSource is bound to an ObservableCollection<Effect> of effects.  This allows us to add effects to the ListBox by simply updating our collection.  Second, our ListBox.IsEnabled is bound to a property in our ViewModel.  Notice the use of TargetNullValue and FallbackValue.  These new properties on the binding extension method allow us to override what gets used in the event the property we are binding to is NULL value.  In this example we have a ViewModel property that stores a reference to a capture that has been selected in the ListBox of captures.  If nothing is selected, the property is null.  Since a null is not a boolean, we use TargetNullValue and FallbackValue to ensure we have a true/false response.

<ListBox Height="50" Name="listEffects" Width="Auto"  HorizontalAlignment="Stretch"
     ItemsSource=
"{Binding Path=Effects}"
     IsEnabled=
"{Binding TargetNullValue=true, FallbackValue=false, Path=SelectedCapture}"
     ItemTemplate=
"{StaticResource EffectItemTemplate}"
     ItemsPanel=
"{StaticResource WrapItemPanel}"
     ScrollViewer.HorizontalScrollBarVisibility=
"Disabled"
     ScrollViewer.VerticalScrollBarVisibility=
"Auto" >
</ListBox>


Another place we use binding is in the DataTemplate of this list box.  Here we will bind both the Effect of the rectangle and its Fill.  Our Effect will get bound to the ShaderEffect property of this item being rendered , while the Fill will navigate back to the main DataContext and bind to a property called Brush located within our  MainPageViewModel.  This property might be a SolidBrush, VideoBrush or even an ImageBrush of an existing capture.

<DataTemplate x:Key="EffectItemTemplate">
    <Border BorderThickness="1" BorderBrush="Black" CornerRadius="2"
        HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,0,3,0">
        <Rectangle Width="48" Height="36" Stretch="Fill"
            Effect="{Binding ShaderEffect}"
            Fill="{Binding Source={StaticResource MainViewModel}, Path=Brush}" />
    </Border>
</DataTemplate>


So that ensures that our list of effects looks correct, but how exactly does our rectangle displaying our live webcam video with the correct ShaderEffect applied?

Again we lean on Binding to avoid any procedural code.  using ElementName binding we bind the styled buttons Effect property to the SelectedItem of our ListBox of effects.  Now each time a user clicks on an item in our list of effects the rectangles will change immediately.

<Button Name="rectVideo"
    Style=
"{StaticResource RectangleButtonStyle}"

    Width=
"320" Height="240"

    Effect=
"{Binding ElementName=listEffects, Path=SelectedItem.ShaderEffect, Mode=TwoWay}"

    Command=
"{Binding Capture}"

    CommandParameter=
"{Binding ElementName=rectVideo}"/>


Reasons why you must trust ASPHostPortal.com

Every provider will tell you how they treat their support, uptime, expertise, guarantees, etc., are. Take a close look. What they’re really offering you is nothing close to what ASPHostPortal does. You will be treated with respect and provided the courtesy and service you would expect from a world-class web hosting business.

You’ll have highly trained, skilled professional technical support people ready, willing, and wanting to help you 24 hours a day. Your web hosting account servers are monitored from three monitoring points, with two alert points, every minute, 24 hours a day, 7 days a week, 365 days a year. The followings are the list of other added- benefits you can find when hosting with us:

- DELL Hardware
Dell hardware is engineered to keep critical enterprise applications running around the clock with clustered solutions fully tested and certified by Dell and other leading operating system and application providers.
- Recovery Systems
Recovery becomes easy and seamless with our fully managed backup services. We monitor your server to ensure your data is properly backed up and recoverable so when the time comes, you can easily repair or recover your data.
- Control Panel
We provide one of the most comprehensive customer control panels available. Providing maximum control and ease of use, our Control Panel serves as the central management point for your ASPHostPortal account. You’ll use a flexible, powerful hosting control panel that will give you direct control over your web hosting account. Our control panel and systems configuration is fully automated and this means your settings are configured automatically and instantly.
- Excellent Expertise in Technology
The reason we can provide you with a great amount of power, flexibility, and simplicity at such a discounted price is due to incredible efficiencies within our business. We have not just been providing hosting for many clients for years, we have also been researching, developing, and innovating every aspect of our operations, systems, procedures, strategy, management, and teams. Our operations are based on a continual improvement program where we review thousands of systems, operational and management metrics in real-time, to fine-tune every aspect of our operation and activities. We continually train and retrain all people in our teams. We provide all people in our teams with the time, space, and inspiration to research, understand, and explore the Internet in search of greater knowledge. We do this while providing you with the best hosting services for the lowest possible price.
- Data Center
ASPHostPortal modular Tier-3 data center was specifically designed to be a world-class web hosting facility totally dedicated to uncompromised performance and security
- Monitoring Services
From the moment your server is connected to our network it is monitored for connectivity, disk, memory and CPU utilization – as well as hardware failures. Our engineers are alerted to potential issues before they become critical.
- Network
ASPHostPortal has architected its network like no other hosting company. Every facet of our network infrastructure scales to gigabit speeds with no single point of failure.
- Security
Network security and the security of your server are ASPHostPortal’s top priorities. Our security team is constantly monitoring the entire network for unusual or suspicious behavior so that when it is detected we can address the issue before our network or your server is affected.
- Support Services
Engineers staff our data center 24 hours a day, 7 days a week, 365 days a year to manage the network infrastructure and oversee top-of-the-line servers that host our clients’ critical sites and services.



About ASPHostPortal.com

We’re a company that works differently to most. Value is what we output and help our customers achieve, not how much money we put in the bank. It’s not because we are altruistic. It’s based on an even simpler principle. "Do good things, and good things will come to you".

Success for us is something that is continually experienced, not something that is reached. For us it is all about the experience – more than the journey. Life is a continual experience. We see the Internet as being an incredible amplifier to the experience of life for all of us. It can help humanity come together to explode in knowledge exploration and discussion. It is continual enlightenment of new ideas, experiences, and passions


Author Link


Corporate Address (Location)

ASPHostPortal
170 W 56th Street, Suite 121
New York, NY 10019
United States

Sign in