Wednesday, October 31, 2012

Retrieving the value from a combo box within a dataform!!

Retrieving the value from a combo box within a dataform!!

Hi there,

I have what should hopefully be a fairly simple question. I have a combobox held within a dataform which is in edit mode. My combobox is bound and populated from an entity collection and is displaying the correct choices, only when I select one and save the changes back the combobox value comes back as null. My xaml code for the combobox is below, I simply want to retrieve the text value held in the combobox.

 

<toolkit:DataField Grid.Column="0" Grid.Row="2" Label="Category" HorizontalAlignment="Stretch"  LabelVisibility="Visible" Mode="Auto" IsReadOnly="False">     <ComboBox Height="Auto" Width="Auto" HorizontalAlignment="Stretch" Name="CategoryCombo" VerticalAlignment="Stretch" SelectedValue="{Binding CATNAME_, Mode=TwoWay}" SelectedItem="{Binding CATNAME_, Mode=TwoWay}" >        <ComboBox.ItemTemplate>            <DataTemplate>                <TextBlock Text="{Binding CATNAME_, Mode=TwoWay}" />            </DataTemplate>         </ComboBox.ItemTemplate>       </ComboBox>  </toolkit:DataField>

Any help is greatly appreciated...

Answers & Comments...

Answer: 1

You might need to write a converter for that. Which will return the desired Text for this.

Let me know if you want me to write the code for you.



Answer: 2

Check this

http://forums.silverlight.net/t/52497.aspx/1



Answer: 3

 Below is the code I use to query the database to populate the combobox.

var GDCategoriesloadOperation = context.Load<GDCategory>(context.GetGDCategoriesbyClientandSchemeQuery(GlobalVariables.currentClientRef, GlobalVariables.selectedSchemeName));  GDCategoriesloadOperation.Completed += new EventHandler(GDCategoriesloadOperation_Completed);  
private void GDCategoriesloadOperation_Completed(object sender, EventArgs e)          {              PolicyCategory = dataForm1_addMember.FindNameInContent("CategoryCombo") as ComboBox;              PolicyCategory.ItemsSource = context.GDCategories;          }


I can retrieve the value as GDCategories:3 which is the correct id for the item but obviously i'd like the text value. Funny I seem to find comboBoxes to be one of the most frustrating things in silverlight



Answer: 4

You are Binding only the CATNAME_ to your combo. How are you getting the ID? I did not see any ID field in the Binding.





Listbox First Item selected in Mvvm

Listbox First Item selected in Mvvm

Hi all,

I am new to mvvm. I have a listbox in my silverlight application which is binded to a observable collection in view model i want to make the listbox with first item selected. I tired this but it doesnt work.

<ListBox Height="431" Canvas.Left="17" Canvas.Top="77" Width="215" FontSize="13" ItemsSource="{Binding Path=Categorys, Mode=TwoWay}" DataContext="{Binding}" SelectedItem="{Binding CurrentCategory, Mode=TwoWay}" ItemTemplate="{StaticResource CategoryDataTemplate}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Name="lst_category">

then i added this in mainpage load of mainpage viewmodel

CurrentCategory = Categorys[0];

can anyone help me



Answers & Comments...

Answer: 1

Can you show the implementation of CurrentCategory?  Have you implemented INotifyPropertyChanged?



Answer: 2

Yes I have implemented INotifyProperty Changed.

private m_category _CurrentCategory=null;     public m_category CurrentCategory          {              get              {                  return _CurrentCategory;              }                set              {                  if (_CurrentCategory != value)                  {                      _CurrentCategory = value;                      OnPropertyChanged("CurrentCategory");                  }              }          }  





Answer: 3

Here is what you need to do:

ViewModel.Cs

public ObservableCollection<ComboItem> ComboItems { get; set; }  private object currentItem;          public object CurrentItem        {           get { return currentItem; }           set {                 currentItem = value;                 PropertyChangedNotify("CurrentItem");           }        }        //constructor        public ViewModel()        {           ComboItems = new ObservableCollection<ComboItem>()           {  new ComboItem() { Id=1, ItemValue="First"},              new ComboItem() { Id=2, ItemValue="Second"},              new ComboItem() { Id=3, ItemValue="Third"}           };             CurrentItem = ComboItems[0];        }  
public class ComboItem : INotifyPropertyChanged     {        private int id;          public int Id        {           get { return id; }           set { id = value; }        }        private string value;          public string ItemValue        {           get { return this.value; }           set           {              this.value = value;              PropertyChangedNotify("ItemValue");           }        }          private void PropertyChangedNotify(string p)        {           if (PropertyChanged != null)           {              PropertyChanged(this, new PropertyChangedEventArgs(p));           }        }            public event PropertyChangedEventHandler PropertyChanged;     }  

ComboBox Binding.
<ComboBox Name="CategoryCombo"                  Width="100"                  Height="20"                  HorizontalAlignment="Stretch"                  VerticalAlignment="Stretch"                  DisplayMemberPath="ItemValue"                  ItemsSource="{Binding ComboItems}"                  SelectedItem="{Binding CurrentItem,                                         Mode=TwoWay}"                  SelectedValuePath="Id" />

and It works.





TreeViewItem with CheckBox - Selection

TreeViewItem with CheckBox - Selection

Hi

I have a treeview and TreeViewItems are added in the treeview.

I need to have a checkbox in each treeviewitem and if i select/check any of the treeviewitem, all childs for selected treeviewitems should be selected/checked.

If i unselect, all child items also unselected.

If i unselect any one of child item and parent item is selected then parent item should be unselected.

Please let me know how can i achieve this.

 

 

Answers & Comments...

Answer: 1

I assume you are binding to some property like "IsChecked" on your tree nodes?  In the setter for taht property, you just need to add the logic to set/unset the appropriate nodes.

1 - You'll have to make your checkboxes tri-state...  (True / False / Indeterminate) to represent this properly.

2 - When setting your current node to true:  set all descendants to true; then set all ancestors to either true or indeterminate (need to evaluate all their descendants to decide)

3 - When setting your property to false - set all descendants to false, then set all ancestors to false or indeterminate (again, you need to evaluate their children to decide)

I'm sure there are more scenarios to this than I am thinking of, but this should get you started at least...



Answer: 2

Hi Cleon,

Thanks for your response.

Actually we are creating treeview custom control and modify the styles and templates.

In treeviewitem control template, i added the checkbox which is mentioned below.

<CheckBox x:Name="CheckBoxElement" Grid.Column="2" IsTabStop="False" Margin="5,0,0,0" Visibility="Visible" VerticalAlignment="Center" />

In onapplytemplate, i get the checkbox object and implement the checkall and uncheckall functionality.

But i could not get the child item checkbox object intially when parent item is in collapsed state due to virtualization. so i unable to check/uncheck the child item check box object when parent item is checked/unchecked.

and also when i uncheck any one of child item when parent item is checked then parent item checkbox should be unselected and also we check parent checkbox and select the expand icon to expand the parent item. here how can we provide child item checkbox selection behaviours.

thanks

suyambu

 

 


 

 





6003 individualization error. Silverlight DRM Component.

6003 individualization error. Silverlight DRM Component.

Some of our clients and developers get 6003 individualization error. Here is what our client wrote:
I am (and some of our users) still seeing error 6003 showing up when trying to play silverlight drm content.
I am running Windows 7 64-bit on a recent model laptop. 
Silverlight version is 4.0.51204. I have tried running internet explorer as admin and also tried the 32-bit version. I also tried running the player as a out of browser application. But I am still getting 6003 error.
What might cause this error? It seems that more and more people starts to get it. Cleaning the PlayReady folder's content doesn't resolve the issue.
6003 individualization error.

Some of our clients and developers get 6003 individualization error.


I am (and some of our users) still seeing error 6003 showing up when trying to play silverlight drm content.


Windows 7 64-bit on a recent model laptop. Most current Silverlight Version.


I have tried running internet explorer as admin and also tried the 32-bit version. I also tried running the player as a out of browser application. But I am still getting 6003 error.


What might cause this error? It seems that more and more people starts to get it. Cleaning the PlayReady folder's content doesn't resolve the issue.


Is anybody from Silverlight group aware of this issue and able to let us know how to resolv it ? 


Best Regards,

Andrew.

Answers & Comments...

Answer: 1

I have the same problem. Was any solution found?

Thanks!



Answer: 2

Unfortunately no, it's just dissapeared. 

I am not even able to replicate the issue, that's the complexity. What system parameters do you have ? 

OS:

Browser version:

Silverlight version: 

Are you able to share the test link to test the content: ? 

If Microsoft would be able to clarify causing reasons for 6003 Error message that would be great but I assume some internal issue happens inside of silverlight runtime or pr client  



Answer: 3

im getting the same problems i have tried everything suggested excluding a system restore as im on a brand new laptop has anyone been able to fix this problem if so i would appreciate help but as simple an explanation as possible i am not very good with technical stuff





Datagrid Grouping collapsed issue

Datagrid Grouping collapsed issue

Hello Team,

We have developed a silverlight 4 application and populated data using Datagrid.This Datagrid has grouping functionality and as we know by default all groups were expanded but as per our requirement we are trying to collapse all groups.

We have nearly 7000 records and by using following code we were able to collapse all groups but it took 2 to 3 min to complete functionality.Customer not at all statisfied with performance.Can any one help us to improve the performance?

foreach (CollectionViewGroup group in (mainGridTrueUp.ItemsSource as PagedCollectionView).Groups)
{
mainGridTrueUp.CollapseRowGroup(group, true);
}

Here mainGridTrueUp is our datagrid.

Thanks in Advance.

Madhan.

Answers & Comments...

Answer: 1

http://subodhnpushpak.wordpress.com/2009/04/22/collapsing-groups-in-silverlight-datagrid/.

http://forums.silverlight.net/t/224651.aspx

http://forums.silverlight.net/p/217667/518299.aspx



Answer: 2

Have you enabled paging in PagedCollectionView? 

http://msdn.microsoft.com/en-us/library/system.windows.data.pagedcollectionview(v=vs.95).aspx 

http://www.c-sharpcorner.com/uploadfile/subhendude/datagrid-paging-in-silverlight-using-wcf-ria-services/ 



Answer: 3

Is it not possible to collapse groups in datagrid which has datapager? Currently I have a datagrid which has groups but could not collapse groups after applying paging.



Answer: 4

Hi Madhan and Arvind_SL, please refer to below code for grouping and paging in DataGrid in Silverlight.

            <data:DataPager x:Name="dataPager1"                              PageSize="5"                              AutoEllipsis="True"                              NumericButtonCount="3"                              DisplayMode="FirstLastPreviousNextNumeric"                              IsTotalItemCountFixed="True"/>              <data:DataGrid AutoGenerateColumns="False" Height="Auto" HorizontalAlignment="Left" Margin="10,10,0,0"                         Name="dataGrid1" VerticalAlignment="Top" Width="Auto">                  <data:DataGrid.Columns>                      <!-- Name Column -->                      <data:DataGridTemplateColumn Header="Name">                          <data:DataGridTemplateColumn.CellTemplate>                              <DataTemplate>                                  <StackPanel Orientation="Horizontal" VerticalAlignment="Center">                                      <TextBlock Padding="5,0,5,0"                              Text="{Binding FirstName}" Width="Auto"/>                                      <TextBlock Text="{Binding LastName}" Width="Auto"/>                                  </StackPanel>                              </DataTemplate>                          </data:DataGridTemplateColumn.CellTemplate>                          <data:DataGridTemplateColumn.CellEditingTemplate>                              <DataTemplate>                                  <StackPanel Orientation="Horizontal">                                      <TextBox Text="{Binding FirstName,Mode=TwoWay}" BorderThickness="0" Width="Auto"/>                                      <TextBox Text="{Binding LastName,Mode=TwoWay}" BorderThickness="0" Width="Auto"/>                                  </StackPanel>                              </DataTemplate>                          </data:DataGridTemplateColumn.CellEditingTemplate>                      </data:DataGridTemplateColumn>                      <!-- Address Column -->                      <data:DataGridTextColumn              Header="Address" Width="Auto"              Binding="{Binding Address}" />                  </data:DataGrid.Columns>              </data:DataGrid>  
        public MainPage()          {              InitializeComponent();                // Wrap the itemList in a PagedCollectionView for paging functionality              PagedCollectionView itemListView = new PagedCollectionView(new Customers());              itemListView.GroupDescriptions.Add(new PropertyGroupDescription("FirstName"));                // Set the DataPager and ListBox to the same data source.              dataPager1.Source = itemListView;              dataGrid1.ItemsSource = itemListView;          }
    public class Customer      {          public int ID { get; set; }          public String FirstName { get; set; }          public String LastName { get; set; }          public String Address { get; set; }            public Customer() { }            public Customer(int id, String firstName, String lastName, String address)          {              this.ID = id;              this.FirstName = firstName;              this.LastName = lastName;              this.Address = address;          }      }      public class Customers : ObservableCollection<Customer>      {          public Customers()          {              Add(new Customer(1, "Michael", "Anderberg",                      "12 North Third Street, Apartment 45"));              Add(new Customer(2, "Chris", "Ashton",                      "34 West Fifth Street, Apartment 67"));              Add(new Customer(3, "Cassie", "Hicks",                      "56 East Seventh Street, Apartment 89"));              Add(new Customer(4, "Guido", "Pica",                      "78 South Ninth Street, Apartment 10"));                Add(new Customer(1, "Michael", "Anderberg",                      "12 North Third Street, Apartment 45"));              Add(new Customer(2, "Chris", "Ashton",                      "34 West Fifth Street, Apartment 67"));              Add(new Customer(3, "Cassie", "Hicks",                      "56 East Seventh Street, Apartment 89"));              Add(new Customer(4, "Guido", "Pica",                      "78 South Ninth Street, Apartment 10"));          }      }

Please feel free to let me know if you have any question.

Best Regards





how to add new stored procedure to existing .edmx file

how to add new stored procedure to existing .edmx file

Hi,

im working on entity framework..i need to add new stored procedure to existing edmx file implementing existing functionalities...i added new stored procedure in this manner Model Browser-->Update Model from dataBase-->checked requared sp-->ok 

everything is ok ,complextype code also generated in MarketSharetool.Designer.cs file but,the main problem is when ever im writting code in 

mainpage.xaml.cs file for retrieving query ,that is not enabled means related sp code is not generating in web.g.cs file.....can you please tell me is there any possible way to add new sp to existing edmx file or need write code in any file....try to give possible reply ASAP..

Thanks

Shukreya.

Answers & Comments...




how to set column datagrid values to read only or not editable

how to set column datagrid values to read only or not editable

i have data grid with text boxes data is getting from edmx. i want set the some datagerid columns to readonly not for all..is it possible ...make sure textboxes code written in datatemplate.

thanks

SHANKAR

Answers & Comments...

Answer: 1

Columns have a "IsReadOnly" property on the columns that you can set to "True"...

<sdk:DataGrid ItemsSource="{Binding ...}" AutoGenerateColumns="False">     <sdk:DataGrid.Columns>        <sdk:DataGridTextColumn Header="Property1" IsReadOnly="True" Binding="{Binding Property1}" />        <sdk:DataGridTemplateColumn Header="Property1" IsReadOnly="True">           <sdk:DataGridTemplateColumn.CellTemplate>              <DataTemplate>                 <TextBlock Text="{Binding Property1}" />              </DataTemplate>           </sdk:DataGridTemplateColumn.CellTemplate>        </sdk:DataGridTemplateColumn>     </sdk:DataGrid.Columns>  </sdk:DataGrid>  

 



Answer: 2

Thanks for giving your valuable reply..issue has been fixed....Thanks again





Fail to hit debug points in one project

Fail to hit debug points in one project

Hello,

I know this topic isn't new but I have a huge problem that I can't solve neither find useful information about it. I can debug all my silverlight projects except for the last one I created. All my projects are GIS maps developed with the API that ESRI provides for the silverlight environment.

I have enabled the silverlight debugging in my last project (the one not working) and followed all the advice given in this forums, but still it's not working. I also tried uninstalling all my workspace (VB2010, silverlight toolkit, ESRI API for silverlight) and reinstall it again. Still all my developments work except one.

Obviously something is wrong in my project but I don't know what. Does anybody know what could cause this behaviour?

Thankyou,

Iker

Answers & Comments...

Answer: 1

See if this helps:

http://boxbinary.com/2010/04/debugging-silverlight-in-visual-studio-breakpoints-not-being-hit/

http://www.blog.ingenuitynow.net/Having+Problems+Debugging+Silverlight.aspx



Answer: 2

Is this project compiled with the Debug option?  Does the Configuration Manager have this project begin compiled?





How to get checkbox checked event in silverlight, from Data Template .

How to get checkbox checked event in silverlight, from Data Template .

Hi all, i am creting a data template at runtime and binding it to a RadCombobox in silverlight.

 Dim radCmb As RadComboBox

radCmb = New RadComboBox
radCmb.Name = "cmb" + index.ToString()

radCmb.Width = 150

Dim template1 As DataTemplate = DirectCast(XamlReader.Load("<DataTemplate xmlns=""http://schemas.microsoft.com/client/2007"">" & vbCr & vbLf & "<StackPanel Orientation=""Horizontal"">" & vbCr & vbLf & "                        <CheckBox Name=""chkSelect"" Content=""{Binding DeviceID}"" Tag=""{Binding InternalDeviceID}""/>" & vbCr & vbLf & "                        <TextBlock Text=""{Binding Name}""/>" & vbCr & vbLf & "                    </StackPanel>" & vbCr & vbLf & "                  </DataTemplate>"), DataTemplate)

radCmb.ItemTemplate = template1

now i need to capture the check box checked and unchecked event and the corresponding checked or unchecked value.

Can you suggest me to achieve this functionality.

thanks

skm

Answers & Comments...

Answer: 1

See if this helps:

http://stackoverflow.com/questions/9413791/how-to-select-all-checkbox-inside-telerik-combox-on-checbox-checked-event



Answer: 2

Can't you just add an IsChecked boolean property to your Viewmodel?  Then just bind to it like you are doing your Text Name property?



Answer: 3

Binding to the IsChecked Property will tell only the state of the checkbox. It will not help to get the Text of the checkbox.

mtiede: Do you think it required a Command and Command Parameter? I am trying to understand, kindly provide your valuable comment.



Answer: 4

You said:

"now i need to capture the check box checked and unchecked event and the corresponding checked or unchecked value."

If whatever structure you have that contains the Name property that is bound to your TextBox also has an IsChecked Boolean property, then you can just bind the CheckBox IsChecked attribute to the IsChecked property of your Viewmodel.

I'm not sure what you mean by: "It will not help to get the Text of the checkbox."  You haven't said there was any relationship between the Text and the IsChecked.

I don't know if a Command is needed, it depends on what you are ultimately trying to do.  I don't think you have stated clearly what you are trying to accomplish.

If you have a Viewmodel that contains both the Name and the IsChecked property and something else that creates the Viewmodel, that other thing can listent for changes to the Viewmodel properties and take actions if they want.  If the Viewmodel itself is to take some action when the property changes, then the Viewmodel can just add the appropriate code when the property setter is called.





Best methods to merge 2 Silverlight solutions?

Best methods to merge 2 Silverlight solutions?

I have two branches of a single Silverlight 5 solution. They are both built off of the same base project. I will be merging one into the other. Some files can be simply copied over, while others will need to merged line by line at the code level.

Thoughts as to the best practices for a merging process on such a large scale such as this?

Tools that may be useful?

Answers & Comments...




How to import a .rtf file to silverlight 4 richtextbox?

How to import a .rtf file to silverlight 4 richtextbox?

I have a .rtf file and want to put it in a richtextbox in silverlight 4. Unfortunately we do not have .rtf property in silverlight 4 richtextbox, we only have .xaml.

So what i did is to create a FlowDocument, than load the .rtf to this FlowDocument, then format it to xaml. then assigned it to richtextbox. But i got a argumentexception.

How to import a .rtf file to silverlight 4 richtextbox?

Thanks!

Answers & Comments...

Answer: 1

I used an ugly solution so far, use a FlowDocument to change the format from rtf to xaml. Then remove the attributes not accepted in SL4 richtext box, codes like below. It works but I hate it. I want to know is there a better solution.

        string xaml = String.Empty;         FlowDocument doc = new FlowDocument();         TextRange range = new TextRange(doc.ContentStart, doc.ContentEnd);          using (MemoryStream ms = new MemoryStream())         {             using(StreamWriter sw = new StreamWriter(ms))             {                 sw.Write(from);                 sw.Flush();                 ms.Seek(0, SeekOrigin.Begin);                 range.Load(ms, DataFormats.Rtf);             }         }           using(MemoryStream ms = new MemoryStream())         {             range = new TextRange(doc.ContentStart, doc.ContentEnd);              range.Save(ms, DataFormats.Xaml);             ms.Seek(0, SeekOrigin.Begin);             using (StreamReader sr = new StreamReader(ms))             {                 xaml = sr.ReadToEnd();             }         }          // remove all attribuites in section and remove attribute margin           int start = xaml.IndexOf("<Section");         int stop = xaml.IndexOf(">") + 1;          string section = xaml.Substring(start, stop);          xaml = xaml.Replace(section, "<Section xml:space=\"preserve\" HasTrailingParagraphBreakOnPaste=\"False\" xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">");         xaml = xaml.Replace("Margin=\"0,0,0,0\"", String.Empty); 
by : freskyhttp://stackoverflow.com/users/304115

Answer: 2

I suggest you take a look at the free VectorLight Rich Text Box control instead.

by : AnthonyWJoneshttp://stackoverflow.com/users/17516

Answer: 3

I need to do something similar (haven't done it yet ...)

I came across NRTFTRee, a C# RTF parser, which should port to silverlight. http://www.codeproject.com/KB/string/nrtftree.aspx

http://nrtftree.sourceforge.net/examples.html

by : Doobihttp://stackoverflow.com/users/308687




How to dynamically pivot non-numerical data?

How to dynamically pivot non-numerical data?

I can create a view with TSQL that pivots my data, but I want the column list to be dynamic so I'd have to use dynamic SQL (regardless of whether I'm using the PIVOT or SELECT CASE method). This would mean the view must be recreated and then updated within LightSwitch when the data to be pivoted to columns changes, which isn't acceptable for me.

If I use WCF RIA Services I'm met with the same problem, the table structure in the code would need updated manually and the data source updated within LightSwitch.

I seem to be on the right track with the various OLAP controls available, they allow dynamic pivoting, and work fantastic with numeric data. They even work fantastic using non-numeric data as row or column fields, which is halfway there. I however want them used as "Values" within my pivot table, but the OLAP controls stick me with using the count() aggregate function on them in this case; something like max() as I'd do with TSQL isn't available.

Here's a couple pictures to illustrate. Here's what I want, except instead of the count() operator being used on my BoughtOn field because it's non-numeric, I want max() used instead (or no aggregate operator at all, whatever) so that I see the actual date. It's worth pointing out that although it doesn't make much sense with this book-related example, on my actual data there won't be more than one instance of the type per row (wouldn't be two+ fantasy books for the owner) so max() if available would work fine, it'd pull the date out amongst null values.

Want but dates not 1s due to count(): enter image description here

Instead the closest I am able to get to something functional is this: enter image description here

which looks fine with my small example, but for my real data I need (want) each Id to be a single row (compare OwnerId = 2 in the two images).

Is there an OLAP control or something similar for LightSwitch that will let me pivot non-numeric data at run-time in the way that I want? (I've looked at pivot views from ComponentOne, Telerik, and Infragistics.)

Answers & Comments...




The HTTP request to *.svc has exceeded the allotted timeout. The time allotted to this operation may have been a portion of a longer timeout.

The HTTP request to *.svc has exceeded the allotted timeout. The time allotted to this operation may have been a portion of a longer timeout.

I have been developing a Silverlight application using WCF.

The problem is that sometimes it throws an exception stating:

"The HTTP request to 'http://localhost:1276/Foo.svc' has exceeded the allotted timeout. The time allotted to this operation may have been a portion of a longer timeout."

So how do I increase the timespan? Some have suggested the usage of receive time out as below in web config and in service.client config file

 <bindings>       <customBinding >         <binding  name="customBinding0" receiveTimeout="02:00:00" >           <binaryMessageEncoding maxReadPoolSize="2147483647" maxWritePoolSize="2147483647" maxSessionSize="2147483647" />             <httpTransport maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" transferMode="Buffered"/>          </binding>       </customBinding>           </bindings> 

what would be the maximum value for the receiveTimeout property?

Answers & Comments...

Answer: 1

How to change it by code: http://blogs.msdn.com/b/kylemc/archive/2010/11/03/how-to-change-the-request-timeout-for-wcf-ria-services.aspx

by : Jonxhttp://stackoverflow.com/users/106404

Answer: 2

I imagine the issue is not that your ReceiveTimeout is beyond the maximum value for that setting, as the MaxValue of a TimeSpan is over 10 million days. Instead, I think the settings are just not taking effect.

You should try increasing the timeout values on both the server and the client-side per this blog post:

On the server (in your web.config)

<binding name="customBinding0" receiveTimeout="00:10:00" sendTimeout="00:10:00" openTimeout="00:10:00" closeTimeout="00:10:00"> 

On the client (in your ServiceReferences.ClientConfig)

<binding name="CustomBinding_DesignOnDemandService" receiveTimeout="00:10:00" sendTimeout="00:10:00" openTimeout="00:10:00" closeTimeout="00:10:00"> 
by : YeahStuhttp://stackoverflow.com/users/1300

Answer: 3

The HTTP request to has exceeded the allotted timeout. The time allotted to this operation may have been a portion of a longer timeout.

Three places to set time values to fix this issue…

  1. Web.Config

    <httpRuntime executionTimeout="600" /> 

    (this is seconds, so here it's 10min). More info on httpRuntime here.

  2. On your Web.Config Binding Elements

    <binding name="customBinding123"     receiveTimeout="00:10:00"     sendTimeout="00:10:00"     openTimeout="00:10:00"     closeTimeout="00:10:00" /> 
  3. On your ServerReferences.ClientConfig binding elements within the system.serviceModel

    <binding name="CustomBinding"     receiveTimeout="00:10:00"     sendTimeout="00:10:00"     openTimeout="00:10:00"     closeTimeout="00:10:00" /> 
by : mounesh hiremanihttp://stackoverflow.com/users/1590220




What are the types of storyboard in silverlight?

What are the types of storyboard in silverlight?

I have recently given an interview. I was asked this question in interview. I read an article [http://bitslot.info/ch13lev1sec1.shtml][1]. This article explain me the types of storyboard. Are active, passive and interactive storyboard are types of storyboard in silverlight?

Answers & Comments...

Answer: 1

Types of Animation (Storyboard) in Silverlight/WPF

  1. DoubleAnimation: This will animate a Double Value from one value to another. So if you want to change the Width of a TextBox over time you need DoubleAnimation.

  2. ColorAnimation: Same as the above if the type of Changing element is Color, you need ColorAnimation.

  3. Transformation: This will animate the rendering of the shape (e.g Ractangle). There are a variety of transformations that can take place, such as stretching, skewing, rotating, etc.

  4. SingleAnimation, RectAnimation, PointAnimation, Int32Animaition, ThicknessAnimation etc each of them bears the same meaning.

So basically the basis of Animation types is based on the type of the property for which you want your animation to work on.

Animation can also be categorized into two basic ways:

  1. Animation Without KeyFrames: These are animation that only needs two values, From and To. It gives you a smooth animation based on the Timeline.DesiredFramerate property for the animation.

  2. Animation With KeyFrames: Allows you to specify a KeyFrame collection which lets you define the KeyFrame value on a specified time. So that you can adjust your own animation based on specific time intervals.

These references might provide you good information further regarding Animation (Storyboard) Types and their Usage:

  1. Introduction to WPF Animations
  2. WPF Tutorial - Styles, Triggers & Animation
  3. Animation Overview
  4. Storyboards Overview
by : Furqan Safdarhttp://stackoverflow.com/users/387058




Binding the number of columns and rows of a Grid

Binding the number of columns and rows of a Grid

I have a WP7 app and so far, I have implemented within an MVVM framework.

I now want to extend this app and part of this involves a grid and I am not sure if I can do what I want to do via binding. Specifically

Will need a variable number of columns - I don't see how I can do this with binding. And if I can then I want to vary the width of the columns depending upon the number of columns

Same with the rows a variable number involved.

I can set up a VM with all the information required here, but I cannot see I can bind to the Grid to make it work. I also want to include some variable data within the grid and again, I cannot see how I can do this with binding. Worked well with a listbox where I have just bound to the collection of objects, but this is quite different.

Is this a case where I should just generate in the code behind? I am happy to do that... but would happily try and do it via binding if its possible.

  • thanks

Answers & Comments...

Answer: 1

You can extend the current Grid control and add some custom Dependency Properties (E.G. Columns and Rows) and bind to these. This would allow you to keep the MVVM pattern.

E.G.

public class MyGridControl : Grid {   public static readonly DependencyProperty RowsProperty =     DependencyProperty.Register("Rows", typeof(int), typeof(MyGridControl), new PropertyMetadata(RowsChanged));    public static readonly DependencyProperty ColumnsProperty = DependencyProperty.Register("Columns", typeof(int), typeof(MyGridControl), new PropertyMetadata(ColumnsChanged));    public static void RowsChanged(object sender, DependencyPropertyChangedEventArgs args)   {     ((MyGridControl)sender).RowsChanged();   }    public static void ColumnsChanged(object sender, DependencyPropertyChangedEventArgs args)   {     ((MyGridControl)sender).ColumnsChanged();   }    public int Rows   {     get { return (int)GetValue(RowsProperty); }     set { SetValue(RowsProperty, value); }   }    public int Columns   {     get { return (int)GetValue(ColumnsProperty); }     set { SetValue(ColumnsProperty, value); }   }    public void RowsChanged()       {     //Do stuff with this.Rows     //E.G. Set the Row Definitions and heights   }    public void ColumnsChanged()   {     //Do stuff with this.Columns     //E.G. Set the Column definitions and widths   } 

If your VM had the properties 'Rows' and 'Columns', the XAML would look like this:

<local:MyGridControl   Rows="{Binding Rows}"   Columns="{Binding Columns}"> </local:MyGridControl> 
by : wdavohttp://stackoverflow.com/users/807836




Could Not Load File Or Assembly for DevExpress Xtrareport in lightswitch

Could Not Load File Or Assembly for DevExpress Xtrareport in lightswitch

i encountered this strange error when i tried to move my lightswitch project from my work laptop to another exact pc everything was working fine .. both laptops have the same specs suddenly i have this error showing when i run my application

i am using the xtraReport Extinsion to do some reports in the application .. what might be the problem ..

i have searched for it and found nothing some people told me its because of silverlight 5, but its installed also in my other laptop and everything is working fine

can any one help me please ??

Could Not Load File Error

Answers & Comments...




Redirect user to desktop browser in windows 8

Redirect user to desktop browser in windows 8

Is there a way to force or prompt a user to use the windows 8 desktop browser if they hit my web page with the windows 8 RT browser? I want to be able to use plugins like Silverlight.

Answers & Comments...

Answer: 1

If you design your website so that it is limited to be used in one browser, people might just avoid using it altogether. I know I would, unless it was a website that I HAD to use. i.e. banking website, or something for work.

Perhaps you should make a cross browser friendly website, and for the more enhanced features create an APP?

by : user1193509http://stackoverflow.com/users/0

Answer: 2

Yes, you can prompt users to switch to the Desktop version. Microsoft added this as a fallback for sites that need it. (But not with JavaScript)

http://blogs.msdn.com/b/ie/archive/2012/01/31/web-sites-and-a-plug-in-free-web.aspx

Developers with sites that need plug-ins can use an HTTP header or meta tag to signal Metro style Internet Explorer to prompt the user.

HTTP Header

X-UA-Compatible: requiresActiveX=true

META Tag

<meta http-equiv="X-UA-Compatible" content="requiresActiveX=true" />

Metro style IE10 detects these flags, and provides the consumer a one-touch option to switch to IE10 on the desktop:

Microsoft is strongly encouraging us, however, to move to an HTM5 plug-in free world. Whether that happens or not remains to be seen, but it wouldn't surprise me if they made it harder and harder to use plug-ins in the future. They're the source of plenty of security holes.

So long-term, it might be better to start eliminating the use of plug-ins in your code. That makes sense considering the plethora of Android, IOS, and other tablets and phones out there. Cross-platform web development has never been more important than it is now, and I'm betting that will continue to be the trend.

by : David Strattonhttp://stackoverflow.com/users/60682




How integrate silverlight 5 in application MAC

How integrate silverlight 5 in application MAC

I have a problem with Silverlight.

I created an application (with Xcode, Obj-c). It contains a WebBrowser to execute a Website that requires Silverlight.

But, Silverlight is very slow on OSX. And for my users is a big problem, because the purpose of this is the speed and NOT a slowness.

So I search a solution to accelerate silverlight on my application. Is it possible?
I thought to integrate the SDK Silverlight in my application, but after?

Answers & Comments...




Radio buttons unchecking

Radio buttons unchecking

I have a created a form for evaulaiton of employees. There is a question and multiple answers which can be checkBoxes, radioButtons, comboBoxes etc.

Which control to display is set by a templateSelector

<Selector.RadioButtonDataTemplate>      <DataTemplate>          <Grid HorizontalAlignment="Stretch">              <Grid.RowDefinitions>                  <RowDefinition MinHeight="30"/>                  <RowDefinition/>                  <RowDefinition Height="5"/>             </Grid.RowDefinitions>              <Grid.ColumnDefinitions>                  <ColumnDefinition Width="20"/>                  <ColumnDefinition Width="*"/>                  <ColumnDefinition Width="20"/>                  <ColumnDefinition Width="Auto"/>             </Grid.ColumnDefinitions>              <StackPanel Orientation="Vertical" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left" Margin="10">                  <ItemsControl ItemsSource="{Binding Options}" >                       <ItemsControl.ItemsPanel>                             <ItemsPanelTemplate>                                   <StackPanel Orientation="Vertical"/>                             </ItemsPanelTemplate>                        </ItemsControl.ItemsPanel>                        <ItemsControl.ItemTemplate>                             <DataTemplate>                                  <RadioButton  IsChecked="{Binding IsClicked,Mode=TwoWay}" Margin="0,0,10,0">                                      <TextBlock Text="{Binding Title}"/>                                  </RadioButton>                             </DataTemplate>                      </ItemsControl.ItemTemplate>                  </ItemsControl>              </StackPanel>          </Grid>     </DataTemplate> </RadioButtonDataTemplate> 

The problem now is if I check a radio button then all other are reset for some reason. I know that this is a normal behaviour if they are inside the same control (stackpanel/grid/etc) but they are in completly different grids. Any ideas?

Answers & Comments...




Passing a complex object to a page while navigating in a WP7 Silverlight application

Passing a complex object to a page while navigating in a WP7 Silverlight application

I have been using the NavigationService's Navigate method to navigate to other pages in my WP7 Silverlight app:

NavigationService.Navigate(new Uri("/Somepage.xaml?val=dreas", UriKind.Relative)); 

From Somepage.xaml, I then retrieve the query string parameters as follows:

string val; NavigationContext.QueryString.TryGetValue("val", out val); 

I now need a way to pass a complex object using a similar manner. How can I do this without having to serialize the object every time I need to pass it to a new page?

Answers & Comments...

Answer: 1

If there is only one instance of your complex object simply pass a flag to Somepage.xaml to indicate it needs to access the object, and add methods to let the Somepage class access the object.

If you have list of these objects, and if they can be uniquely identified, then pass the identifier to Somepage.xaml and add a Find( myComplexObjectID ) method to the class holding these objects.

If they cannot be uniquely identified you'll have to do serialization of some sort. Either write the object to IsolatedStorage or convert it to a string (could be an XML string if you want to use XmlSerializer) and pass it as a query string. Also, if you do choose the query string option, don't forget to escape it using Uri.EscapeDataString(). You don't need to unescape it while reading, NavigationContext automatically does that for you.

by : Praetorianhttp://stackoverflow.com/users/241631

Answer: 2

App.xaml.cs -> App class, add a field/property there. To access it, if it is static use:

App.MyComplexObject 

Or if is not staic

(App.Current as App).MyComplexObject; 
by : lukashttp://stackoverflow.com/users/336186

Answer: 3

This is an extremely complex problem, and there is no simple solution here. There is no magic API that would just work for any app to solve this problem.

The core problem with passing navigation data is Tombstoning. The only piece of data that is tombstoned by default is the Navigation URI. so if you're using a QueryString parameter, it'll get picked up automatically by tombstoning and your code. Any time you'll manually pass a instance of an object though, you'll have to manually do tombstoning for that instance yourself.

So, if you navigate to "/CowDetails.xaml?ID=1" your page will probably have perfect tombstoning just by picking up on the ID Querystring Parameter. However, if you somehow provide CowDetails page with a "new Cow() { ID = 1}" you'll have to make sure to tombstone and zombificate this value yourself.

Also, there's the issue of timing. While calling NavigationService.Navigate, the page you're navigating too doesn't have an actual instance yet. So even though you're navigating to FooPage and have the FooData ready, there's no way to immediately connect FooPage to FooData. You'll have to wait until the PhoneApplicationFrame.Navigated event has fired in order to provide FooPage with FooData.

The way I normally deal with this is problem:

  1. Have a BasePage with an Object type Data property
  2. Have a NavigationHelper get the page URI and Data: NavigationHelper.Navigate("foo.xaml", fooData)
  3. Have NavigationHelper register to PhoneApplicationFrame.Navigated event and if it's "foo.xaml" set the BasePage.Data to FooData.
  4. Have BasePage use JSON.Net to tombstone and zombificate BasePage.Data.
  5. On BasePage, I've got a OnDataSet virtual method that is invoked once the Data property is populated either by Zombification or Navigation. In this method, everything that has to do with business data happens.
by : JustinAngelhttp://stackoverflow.com/users/81687

Answer: 4

Debatable solution, if anything, make it temporary.

Create this under the namespace of your application for whichever page necessary.

public static class VarsForPages {      // Be sure to include public static.     public static SomeClass SomeClassObject;     public static List<string> SomeList = new List<string>();     public static string SomeData = "SomeValue";  }  // The syntax for referencing the data    VarsForPages.SomeClassObject;     VarsForPages.SomeList;     VarsForPages.SomeData; 

Now you can reference SomeClassObject, SomeList, SomeData anywhere in the application.

Note: Like any global data, be weary of the many accesses & modifications which may be done to the global data. I say this, because I once had a list increase in size, but one of my pages in the application relied on the size of the list to be of some value, and this caused a bug. Don't forget, the data is global.

by : Ryanhttp://stackoverflow.com/users/1061644

Answer: 5

There's a very simple solution to tackle this problem. Consider the following example A windows phone app has following two pages, Page1.xaml and Page2.xaml Lets say from Page1.xaml we are navigating to Page2.xaml. The navigation cycle starts, when you call NavigationService.Navigate method

  1. First OnNavigatingFrom Event of Page1 fires
  2. Then Constructor of Page2 fires
  3. Then OnNavigatedFrom event of Page1 fires with the reference of the created page in its EventArgs (e.Content has the created instance of Page2)
  4. Finally OnNavigatedTo Event of Page2 fires

So we are getting the other page's reference in the page where the navigation starts.

public class PhoneApplicationBasePage : PhoneApplicationPage {  private object navParam = null; protected object Parameter{get;private set;} //use this function to start the navigation and send the object that you want to pass  //to the next page protected void Navigate(string url, object paramter = null)  {        navParam = paramter;    this.NavigationService.Navigate(new Uri(url, UriKind.Relative));  }  protected override void OnNavigatedFrom(NavigationEventArgs e) { //e.Content has the reference of the next created page if (e.Content is PhoneApplicationBasePage )   {    PhoneApplicationBasePage  page = e.Content as PhoneApplicationBasePage;    if (page != null)    { page.SendParameter(navParam); navParam=null;}   } } private void SendParameter(object param) {  if (this.Parameter == null)   {    this.Parameter = param;    this.OnParameterReceived();   } } protected virtual void OnParameterReceived() { //Override this method in you page. and access the **Parameter** property that // has the object sent from previous page } } 

So in our Page1.xaml.cs we simply call Navigate("/Page2.xaml",myComplexObject). And in your Page2.xaml.cs we will override OnParameterReceived method

 protected override void OnParameterReceived() { var myComplexObjext = this.Parameter; } 

And it is also possible to handle tombstone problems with little more tweaks in PhoneApplicationBasePage

by : vjsrinathhttp://stackoverflow.com/users/1069018




Is C#, XAML, Sliverlight, WPF going to die? [closed]

Is C#, XAML, Sliverlight, WPF going to die? [closed]

I really do not know what is going on, for once I felt like Microsoft made something I did like which is XAML.

Now, we are all seeing that Microsoft has a new spoiled child HTML5/JS.

Leaving the fact that I do not like that my application will be in clear text. I really do not understand why would Microsoft would such thing.

Is it for other platforms compatibility?

Why would any body now bother learn Silverlight or WPF as they are fading away?

I know that Microsoft would say

"Do not panic, we are still going to support the product"

but this is just to absorb the rage of the existing WPF/SL developers.

And if anything history had shown us that all companies would say such thing before dumping the technology.

My Question is: is HTML5/JS is going to take over C# and its technologies (Silverlight,WPF, XAML)?

No Answer and comments so far




Display two different ValidationSummary controls on single view. Silverlight

Display two different ValidationSummary controls on single view. Silverlight

What I need to do if I want display two different ValidationSummary controls on my view? First control is the control which display regular validation errors, it's simple. Second one is the ValidationSummary control which should contains warnings, but not errors.

To achieve this I tried to follow this steps:

  1. Add new property to my ViewModel. The property implements INotifyDataErrorInfo interface and inherited from FrameworkElement.
  2. Set ValidationSummarys' Target binding to the property.
  3. When adding new warning to collection calling ErrorChange of the property.

But ValidationSummary do not show any warnings. Even do not subscribes to ErrorChange event of this property.

What I am doing wrong?

Answers & Comments...




WCF How to Check If All Callbacks are OK

WCF How to Check If All Callbacks are OK

What is the best way to check if all clients are OK in a WCF Polling Duplex connection ?

I'm designing a silverlight game and storing the players in a dictionary in a Pub/Sub model (I have a SubscriptionManager object to handle these process). I can handle the logouts with via a button but I couldn't handle it for unexpected logouts.

Answers & Comments...




Grid auto width

Grid auto width

The question is simple as 1x1 and I suppose the answer is also that simple.

I would like to fit my grid's width and height to it's content. So if I change the content's size from code I would like the grid to have the same size.

I've tried the following:

    <Grid x:Name="ContainerGrid" Background="Cyan" MouseDown="ContainerGrid_Tapped_1">         <Grid.ColumnDefinitions>             <ColumnDefinition Width="Auto" />             <ColumnDefinition Width="Auto"/>         </Grid.ColumnDefinitions>         <Grid.RowDefinitions>             <RowDefinition Height="Auto"/>             <RowDefinition Height="Auto"/>         </Grid.RowDefinitions>         <StackPanel Grid.Column="0" Grid.Row="1">             <Rectangle x:Name="small" Fill="Red" Width="100" Height="100" Visibility="Visible"/>             <Rectangle x:Name="big" Fill="Green" Width="500" Height="500" Visibility="Collapsed"/>         </StackPanel>         <Grid x:Name="SelectedCheckMark"  Grid.Column="1" Grid.Row="0" Visibility="{Binding ElementName=big,Path=Visibility}">             <Path x:Name="SelectedEarmark" Data="M0,0 L40,0 L40,40 z"                    Fill="BlueViolet" Stretch="Fill"/>             <Path Data="F1 M133.1,17.9 L137.2,13.2 L144.6,19.6 L156.4,5.8 L161.2,9.9 L145.6,28.4 z"                    Fill="White" FlowDirection="LeftToRight"                    HorizontalAlignment="Right" Height="15"  Stretch="Fill" VerticalAlignment="Top" Width="15"/>         </Grid>     </Grid> 

Code behind relevant part:

    private void ContainerGrid_Tapped_1(object sender, MouseButtonEventArgs e)     {         //Set opoosite visibility         small.Visibility = (small.Visibility == Visibility.Visible) ? Visibility.Collapsed : Visibility.Visible;         big.Visibility = (big.Visibility == Visibility.Visible) ? Visibility.Collapsed : Visibility.Visible;     } 

I would like that no Cyan color could be seen in any state of the grid. However now the width of the ContainerGrid does not fit to it's content.

What I've missed?

Answers & Comments...

Answer: 1

Try changing your XAML to the following:

<Grid x:Name="ContainerGrid" Background="Cyan" MouseDown="ContainerGrid_Tapped_1" HorizontalAlignment="Center" VerticalAlignment="Center">     <Grid.ColumnDefinitions>         <ColumnDefinition Width="Auto" />         <ColumnDefinition Width="Auto"/>     </Grid.ColumnDefinitions>     <Grid.RowDefinitions>         <RowDefinition Height="Auto"/>         <RowDefinition Height="Auto"/>     </Grid.RowDefinitions>     <StackPanel Grid.Column="0" Grid.Row="1">         <Rectangle x:Name="small" Fill="Red" Width="100" Height="100" Visibility="Visible"/>         <Grid>             <Rectangle x:Name="big" Fill="Green" Width="500" Height="500" Visibility="Collapsed"/>             <Grid x:Name="SelectedCheckMark"  Grid.Column="1" Grid.Row="0" Visibility="{Binding ElementName=big,Path=Visibility}" HorizontalAlignment="Right" VerticalAlignment="Top">                 <Path x:Name="SelectedEarmark" Data="M0,0 L40,0 L40,40 z"                        Fill="BlueViolet" Stretch="Fill"/>                 <Path Data="F1 M133.1,17.9 L137.2,13.2 L144.6,19.6 L156.4,5.8 L161.2,9.9 L145.6,28.4 z"                        Fill="White" FlowDirection="LeftToRight"                        HorizontalAlignment="Right" Height="15"  Stretch="Fill" VerticalAlignment="Top" Width="15"/>             </Grid>         </Grid>     </StackPanel> </Grid> 
by : Eirikhttp://stackoverflow.com/users/773118

Answer: 2

Try to work with HorizontalAlignment and VerticalAlignment Properties of ContainerGrid.

For example

<Grid x:Name="ContainerGrid" Background="Cyan" MouseDown="ContainerGrid_Tapped_1" Margin="0,0,0,0" ShowGridLines="True" Height="Auto" Width="Auto" HorizontalAlignment="Left" VerticalAlignment="Top"> 

Their default value is Stretch, which means the grid will stretch within the entire space given by its parent element irrespective of the content.

by : Klaus78http://stackoverflow.com/users/592318




How to hide xaml ui element in debug

How to hide xaml ui element in debug

I create a textbox in xaml to monitor a value. this is useful when developing but i would like to hide it when running in release compile. i know i can hide the texbox by setting visibility, but i would like to automate it.

thanks.

Answers & Comments...

Answer: 1

I´m not sure if you can do this directly in XAML by defining conditional compilation directives. But it should work using the codebehind file.

First give your TextBox a name to access it in the codebehind file.

<TextBox x:Name="debugTextBox" /> 

and then add code to your codebehind (like the constructor)

#if DEBUG   debugTextBox.Visibility == Visibility.Visible; #else   debugTextBox.Visibility == Visibility.Hidden; // or Collapsed 

"No symbols have been loaded" - Silverlight project cannot find pdb files

"No symbols have been loaded" - Silverlight project cannot find pdb files

I've got a web project that runs a Silverlight app. Due to the massive build times I am trying to use "Attach to Process" instead of running in debug in Visual Studio.

When I build the full solution I can attach fine, but when I make a change and build the changed project I get "The breakpoint will not be currently hit. No symbols have been loaded for this document".

If I check the modules window and look at the the offending project I see "Cannot find or open the PDB file". I check the load information and it says "C:\Source\Project\Web\bin\myProject.pdb: PDB does not match image.: PDB does not match image."

After the build of the single project the following files are updated: C:\Source\Project\Web\bin\myProjectName.pdb C:\Source\Project\Web\bin\myProjectName.dll C:\Source\Project\Web\ClientBin\myProjectName.xap C:\Source\Project\bin\Debug\myProjectName.pdb C:\Source\Project\bin\Debug\myProjectName.dll C:\Source\Project\bin\Debug\myProjectName.xap C:\Source\Project\myProjectName\obj\Debug\myProjectName.pdb C:\Source\Project\myProjectName\obj\Debug\myProjectName.dll C:\Source\Project\myProjectName\bin\Debug\myProjectName.pdb C:\Source\Project\myProjectName\bin\Debug\myProjectName.dll

So everything looks ok. The same files are updated if I do a full rebuild.

I've tried copying the contents of the build folder into the Web bin folder. I've tried setting Symbols file locations for all of the above folders.

Thanks!

Answers & Comments...

Answer: 1

Are you sure C:\Source\Project\Web\ClientBin\myProjectName.xap file is changing. Check FileLastWriteDate. And follow my previous post about this issue.

http://stackoverflow.com/a/12781653/413032

Hope helps.

by : Davut Gürbüzhttp://stackoverflow.com/users/413032




SIlverlight 5 RIA composition child entity delete

SIlverlight 5 RIA composition child entity delete

I'm using a custom library which generates the DAL for me similar to Entity Framework but not identically and am having a problem using it imposed by RIA. My problem is that the custom DAL produces an IsPersisted property which essentially identifies if the entity has a corresponding DB record. The key part of the delete code looks like ... if(this.IsPersisted) dataAccessor.Delete(); else throw new NotSupportedException("Delete not supported on unpersisted entities.");

The problem comes in when I use RIA to generate the medium between client and server. I have a parent class with a child composition property like class Parent{ ... [Include,Association("Parent_Child","ParentId","ParentId",IsForeignKey=false), Composition] public List Children{get{return (_children = _children??new List());}} }

In the client code, if I then use parent.Children.Remove(child); the correct entity action is relayed to the server but for the IsPersisted flag gets changed to false when the change set is generated which in turn causes a NotSupportedException.

I've done a lot of digging and exploring. After examining the actual network traffic back to the server I see that the ChangeSet being sent to the server actually contains the flaw. It correctly exposes the original entity and values but then in the Delete segment of the changeset I can see the same entity (verified by the same identity) specified again as OriginalEntity but this time all the values are empty except the ID.

If I trace the deserialization of the ChangeSet, I can see it actually create two separate instances of Child, first populated correctly, then again zeroed out. The ChangeSet then only holds the zeroed out version of the child.

Any ideas as to how to fix what RIA is sending up the wire?

Answers & Comments...




Drag & Drop needs a math fix

Drag & Drop needs a math fix

I have a drag/drop behavior for my RichTextBox in Silverlight 4, but i'm having a small snapping problem.

I would like the user to be able to "grab" any border of the RichTextBox and drag/drop it. The RichTextBox should drag relative to where the user "grabbed" the RichTextBox. But instead, as soon as the user begins the drag, the RichTextBox "snaps" to the middle of the mouse position instead of its position staying relative to the mouse position.

So if I grab the bottom right corner, as in the following ...

https://skydrive.live.com/redir?resid=DCC93DD825EF3F43!658

it "snaps" to the middle of the mouse position on the start of the dragging, as in the following ...

https://skydrive.live.com/redir?resid=DCC93DD825EF3F43!659

Here's my dragging code. I'm assuming my math is wrong (in the MouseMove event) ???


public class CustomRichTextBox : RichTextBox {     private bool isDragging = false;      protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)     {         base.OnMouseLeftButtonDown(e);          bool isDragAllowed = false;         Point pt = e.GetPosition(this);          if (pt.Y >= 0 && pt.Y <= this.BorderThickness.Top)             // Allow dragging if the mouse is down on the top border             isDragAllowed = true;         else if (pt.Y >= (this.RenderSize.Height - this.BorderThickness.Bottom) && pt.Y <= this.RenderSize.Height)             // Allow dragging if the mouse is down on the bottom border             isDragAllowed = true;         else if (pt.X >= 0 && pt.X <= this.BorderThickness.Left)             // Allow dragging if the mouse is down on the left border             isDragAllowed = true;         else if (pt.X >= (this.RenderSize.Width - this.BorderThickness.Right) && pt.X <= this.RenderSize.Width)             // Allow dragging if the mouse is down on the right border             isDragAllowed = true;          if (!isDragAllowed)             return;          this.CaptureMouse();         isDragging = true;     }      protected override void OnMouseMove(MouseEventArgs e)     {         base.OnMouseMove(e);          if (isDragging)         {             CustomRichTextBox elem = this;             CompositeTransform ct = (CompositeTransform)elem.RenderTransform;             UIElement parent = (UIElement)elem.Parent;              ct.TranslateX = e.GetPosition(parent).X - (parent.RenderSize.Width / 2);             ct.TranslateY = e.GetPosition(parent).Y - (parent.RenderSize.Height / 2);         }     }      protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)     {         base.OnMouseLeftButtonUp(e);          isDragging = false;         this.ReleaseMouseCapture();     } } 

Answers & Comments...




PagedCollectionView not found in Silverlight 4 (again? yes)

PagedCollectionView not found in Silverlight 4 (again? yes)

I know this will sound quite redundant, but sadly, no answer I have found to this problem online helped me.

I am running Visual Studio 2010, and using the Silverlight 4 SDK (April 2011 version) for my project. (set in the properties, I double-checked)

I did add "using System.Windows.Data;" at the beginning of my .cs file.

Yet, the compiler still gives me "not found" errors concerning my calls to PagedCollectionView.

When I type "System.Windows.Data.", the completion gives me plenty of suggestions, but no "PagedCollectionView"... the first suggestion I get starting with P is "PropertyGroupDescription".

Has this useful tool just been erased out of the surface of the Earth?

Thanks

Answers & Comments...

Answer: 1

You need to add a reference to assembly System.Windows.Data for PagedCollectionView.

The namespace System.Windows.Data is used in multiple assemblies for example System.Windows that contains PropertyGroupDescription

by : Jehofhttp://stackoverflow.com/users/83039




Vectorlight RichTextBox strange behavior

Vectorlight RichTextBox strange behavior

In my SL5 app i created a a usercontrol with a toolbor and the richtext to manipulate and customize the content of richtextbos.(like here)

I'm using this custom control in a floatable window which is instantiated only one time at starting of my application and i show and close the window.

My first problem is with multi-line content. The first time i show the child it render the content correclty the second time showing the window(with same data) the multi-line content is merged/overlapped in the first one line. The third i show the child it render correctly the fourth time i have same problem and so on.

This is what i get: http://i.stack.imgur.com/24nfe.png

Answers & Comments...




Silverlight5 - Binding breakpoint not hit in ItemsControl

Silverlight5 - Binding breakpoint not hit in ItemsControl

Using VS2012 and SL5.

When I set a breakpoint on the Content={Binding} and hit debug, the code works, but the breakpoint is never hit. Why?

Have tried restarting studio (this works when I sometimes can't set a red dot breakpoint in code).

<Grid Grid.Row="5">     <ItemsControl>         <ItemsControl.Items>             <Button Content="First" />             <Rectangle Width="20" Height="20" />             <Button Content="Second" />             <Rectangle Width="20" Height="20" />             <Button Content="Third" />         </ItemsControl.Items>          <ItemsControl.ItemsPanel>             <ItemsPanelTemplate></ItemsPanelTemplate>         </ItemsControl.ItemsPanel>          <ItemsControl.ItemTemplate>             <DataTemplate>                 <Button Content="{Binding}" />             </DataTemplate>         </ItemsControl.ItemTemplate >     </ItemsControl> </Grid> 

enter image description here

Answers & Comments...

Answer: 1

I think I know why it didn't hit... no default binding has been setup. This works below on the binding breakpoints.

<Grid Grid.Row="5">     <!-- bind to the Data property of element AccountsDataSourceT32 -->     <ItemsControl ItemsSource="{Binding Data, ElementName=AccountsDataSourceT32}">         <ItemsControl.ItemsPanel>             <ItemsPanelTemplate></ItemsPanelTemplate>         </ItemsControl.ItemsPanel>          <ItemsControl.ItemTemplate>             <DataTemplate>                 <Button Content="{Binding Username}" />             </DataTemplate>         </ItemsControl.ItemTemplate >     </ItemsControl> </Grid> 
by : Dave Mateerhttp://stackoverflow.com/users/26086




System not supported exception in IAsyncResult

System not supported exception in IAsyncResult

i am trying to use HttpWebRequest for accessing a server. My application used to work on win7 and phone sdk 7.1 but now i upgraded to win8 and phone sdk 8, though my project is still for windows phone 7.1

Getting following exception in IAsyncResult.ASyncWaitHandle

base = {System.NotSupportedException: Specified method is not supported.    at System.Net.Browser.OHWRAsyncResult.get_AsyncWaitHandle()} 

Answers & Comments...

Answer: 1

Await/Async isn't compatible with WP7 or WP7.1

it's a new .Net 4.5 feature and not usable for these projects (which are basically Silverlight 3/4 projects).

by : Faster Solutionshttp://stackoverflow.com/users/890018




silverlight build a datagrid in the code behind

silverlight build a datagrid in the code behind

Is it possible in a Silverlight DataGrid to have a column that has rows with different types of controls? For instance the first two rows of the column should be text, the next two rows would have buttons and then the next 6 rows would have Checkboxes. I need to build it in the code behind also. Any help would be appreciated.

Answers & Comments...

Answer: 1

Maybe the code below code gives you the idea.

        foreach (var item in ItemList)         {             //Row definition and column definitions are similar             LayoutRoot.RowDefinitions.Add(new RowDefinition()              { Height = GridLength.Auto});                       HelloObject hl=new HelloPObject();              //Attached property imeplemantation             Grid.SetRow(hl,Layout2.RowDefinitions.Count);              //You may add any UIElement as Children             LayoutRoot.Children.Add(hl);                         } 
by : Davut Gürbüzhttp://stackoverflow.com/users/413032




Get submitted Entity with server made changes back to the Client when Insert on SubmitChanges()

Get submitted Entity with server made changes back to the Client when Insert on SubmitChanges()

I am working on a SOA Architecture. So I donot have access to database. I use DTO's on the server as entities.I fill in an entity on the client and submit it to the server and that is when a primary key is generated for the entity.

And I use (client Side)

_customerDomainContext.SubmitChanges(SubmitChangesCallback, null);

In the callback when I try to access the newly added enity, I only can see the properties which I filled in.

I have access to the submited entity on the domain Service(server Side) as show below.

   [Insert]     public void InsertCustomerDTO(CustomerDTO customer)     {       CustomerDTO customerFromDB = CreateCustomerDTOCore(customer);     } 

Is there a way I get the newly generated Entity to the client so that I can access the entity's newly generated Key on SubmitChanges.

Any Suggestion is kindly appreciated.

Answers & Comments...

Answer: 1

Simply use the argument of the callback:

context.SubmitChanges(x =>             {                 //Contains your entities fulfilled by the server                 x.ChangeSet             }, null); 

It contains the entities RETURNED by the server after thy have been saved, so in your key field you'll find the actual key value.
In order for the above process to run, may not be obvious that you need to "edit" your entities.

[Insert] public void InsertJeopardyModel(CustomerDTO jeopardy) {     CustomerDTO customerFromDB = CreateCustomerDTOCore(customer);     jeopardy.Id = customerFromDB.Id;     jeopardy.MyProperty = customerFromDB.MyDBEquivalentProperty; } 

As you can see in the edited sample I'm actually editing the CustomerDTO object, just like Enitity Framework or LINQ2SQL does.
That edited entity will then be serialized to the client that will expose it in the Changeset property.

by : mCasamentohttp://stackoverflow.com/users/363198




How to find the instance of a control in silverlight?

How to find the instance of a control in silverlight?

I have the following XAML where myList is a user control. On that user control I have a textblock and a delete button. When a user presses the delete button, I want to delete the instance of that selected user control. How do I do that? Thanks.

Answers & Comments...

Answer: 1

Why not use visibility.collapsed instead of deleting control from objects tree?

by : Dima Martovoihttp://stackoverflow.com/users/976231




SL40PropertyGrid Button property

SL40PropertyGrid Button property

I am working with silverlight property grid (http://slg40.codeplex.com/). I would like to put "Button" as property in this grid and implement "click" of this button.

Main task is: There is workspace(schema) with objects, properties of object are shown in grid, some of objects have thier own schema as a property. I want to show this on clicking button in grid.

Now only simple types can be shown in grid. If i add complex type it show result of "ToString()" and small button. By the way it can be solution but i can't override Click of this button.

Maybe someone had already solved such task?

Answers & Comments...




Show Hide Silverlight Controls from the page

Show Hide Silverlight Controls from the page

I have a dataGrid control on the page and below this grid there are some text boxes. in some conditions I dont want to display the grid on the page. For this I have used

dg.Visibilty = Visibilty.Collapse;

It will successfully hide the datagrid, which is fine, but the space that is consumned by the grid is still disply on the page, what I want is when my grid is hidden then controls will shift up automatically just like style=display:none ;

Thanks

Answers & Comments...

Answer: 1

What you are doing should work fine.

It might be that the container which contains your data grid might have some height width assigned.

by : Fahim A. Salimhttp://stackoverflow.com/users/1474494




Bold single word inside Silverlight DataField label

Bold single word inside Silverlight DataField label

Imagine I have a simple DataField in my Silverlight app. something like this:

<toolkit:DataField Label="This is my test label:">   <TextBox ... etc... /> </toolkit:DataField> 

Is it possible to style the label in above example so that only the word "test" is bold?

Answers & Comments...

Answer: 1

you can use Run tag inside a textblock tag like this :

<toolkit:DataField >      <toolkit:DataField.Label>          <TextBlock >This is my <Run FontWeight="Bold">test</Run>label</TextBlock>      </toolkit:DataField.Label>       <TextBox ... etc... /> </toolkit:DataField> 

i hope that it fixe your pb.

by : erradi mouradhttp://stackoverflow.com/users/1049530