|
Hi,
I am trying to populate a grid on the silverlight page:
as
follows:
...
...
grid.ItemsSource = e.Result.DetailedData;
Note that e.Result.DetailedData.count returns 13 records but on the above line I get the error:
can not implicitly convert type 'xweb.tservice.clsbt' to system.collections.ienumerable. An explicit conversion exists. (Are you missing a cast?)
It seems I have to do a cast but not sure how?
Any thoughts please?
Thanks
|
|
|
|
|
In wpf I put my ItemsSource="{Binding}" in XAML.
In code you then do : grid.ItemsSource = my_collection_of_some_sort;
hope this helps.
V.
|
|
|
|
|
the datagrid is set as AutoGenerateColumns="False"
And still get the same error as before but this time there is a blue underline instead of the previous red underline.
|
|
|
|
|
In XAML
<ListView Name="lv_countries" ItemsSource="{Binding}" SelectionChanged="lv_countries_SelectionChanged">
<ListView.View>
<GridView>
<GridViewColumn Header="Code" Width="Auto" DisplayMemberBinding="{Binding Path=Code}" />
<GridViewColumn Header="Country" Width="Auto" DisplayMemberBinding="{Binding Path=Name}" />
</GridView>
</ListView.View>
</ListView>
In code behind.
lv_countries.DataContext = countrylistresponse.CountryList;
where countrylistresponse.CountryList is an array of Country class. Country class has two properties: Code and Name (see XAML)
I'm not sure what kind of type e.Result.DetailedData is. You could try setting AutoGenerateColumns to "True" or define the columns in XAML.
PS: I know my sample is a ListView, but the principle is the same. Note however that WPF and Silverlight are slightly different. Could be that you have to call eg "DataBind()" method like you have to don in Aspx. I don't know. If VS gives you a blue bar under the statement it should tell you something when you hover over the statement...
hope this helps.
V.
|
|
|
|
|
For the record
In wpf I put my ItemsSource="{Binding}" in XAML.
In code you then do : grid.ItemsSource = my_collection_of_some_sort;
Should have been:
In wpf I put my ItemsSource="{Binding}" in XAML.
In code you then do : grid.DataContext = my_collection_of_some_sort;
Make sure that the e.Result.DetailedData is a collection like a List, Dictionary or an array.
Sorry about the confusion.
V.
|
|
|
|
|
Thank you
modified 30-Dec-11 17:17pm.
|
|
|
|
|
|
|
Hi @all,
i know that there a many articles about my problem but i cant find a solution.
I am new in WPF - MVVM and i try to understand the MVVM-Logic.
So i made a little project to understand that.
For my later apps i want to load UserControls dynamicly to my Window.
In my StartView i have a Binding to the StartViewModel.
(The Binding is in the APP.xaml)
StartView app = new StartView();
StartViewModel context = new StartViewModel();
the StartView
<Window x:Class="test.Views.StartView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:views="clr-namespace:test.ViewModel"
Title="Window1" Height="300" Width="516">
<Grid>
<Menu IsMainMenu="True" Margin="0,0,404,239">
<MenuItem Header="_Einstellungen">
<MenuItem Header="Server" />
</MenuItem>
</Menu>
<ContentControl Content="{Binding LoadedControl}" Margin="0,28,0,128" />
</Grid>
</Window>
the StartViewModel
namespace test.ViewModel
{
public class StartViewModel : ViewModelBase
{
#region Fields
private UCStastistikViewModel _loadedControl;
#endregion
public StartViewModel()
{
LoadedControl = new UCStastistikViewModel();
}
#region Properties / Commands
public UCStastistikViewModel LoadedControl
{
get { return _loadedControl; }
set
{
if (value == _loadedControl)
return;
_loadedControl = value;
OnPropertyChanged("LoadedControl");
}
}
#endregion
#region Methods
#endregion
}
}
UCStatistikView
<UserControl x:Class="test.Views.UCStatistik"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vm="clr-namespace:test.ViewModel"
mc:Ignorable="d"
d:DesignHeight="188" d:DesignWidth="508">
<UserControl.DataContext>
<vm:UCStastistikViewModel />
</UserControl.DataContext>
<Grid Background="red">
</Grid>
</UserControl>
UCStatistikViewModel
namespace test.ViewModel
{
public class UCStastistikViewModel : ViewModelBase
{
#region Fields
#endregion
public UCStastistikViewModel()
{
}
#region Properties / Commands
#endregion
#region Methods
#endregion
}
}
Now i want to load my UCStatistikView in the ContentControl of my StartView.
But in the Startview only the Path test.UCStatistikViewModel is shown instead of the whole UC
Can anybody give me some Ideas to Fix it ?
Bye jogi
|
|
|
|
|
The standard way to display a usercontrol like this is to use a DataTemplate. Here's a simple data template that you could take and adapt as you need:
<DataTemplate DataType="{vm:UCStastistikViewModel}">
<view:UCStatistikView />
</DataTemplate>
|
|
|
|
|
hi
i am making a windows phone app which reads the text from the content file in project.How can we read the text of the content file into a text box .
Is there any way to bind the file with button and then read the file on click event?
Plz help
Thanks in advance
|
|
|
|
|
I need to implement payment process in silver light using ssl.
Anyone have idea on it?
|
|
|
|
|
saroja241 wrote: I need to implement payment process in silver light using ssl.
I believe, it's possible, however no one want to develop payment gateway in silverlight, since it's front end and reside on client computer. if you mean to say you want to get all information regarding client details and credit card through silvelight front-end, then that possible, you can call webservice to communicate to server about this information and based on what is returned, code your logic
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
The program runs perfectly on my machine but when I try to execute it on an other machine, it crashes after the splash screen. I have checked the event viewer and I have copied the following stack report. I am sure that if can access the details of the inner exception to see what causes the crash I am also sure that I would be able to solve my problem. I have already lost 1 week because of this issue. Please give me an idea for solution and sorry for my poor English.
Uygulama: Safir.exe
Framework Sürümü: v4.0.30319
Açıklama: İşlenmeyen bir özel durum nedeniyle işlem sonlandırıldı.
Özel Durum Bilgisi: System.Windows.Markup.XamlParseException
Yığın:
konum: System.Windows.Markup.XamlReader.RewrapException(System.Exception, System.Xaml.IXamlLineInfo, System.Uri)
konum: System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)
konum: System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri)
konum: System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean)
konum: System.Windows.Application.LoadBamlStreamWithSyncInfo(System.IO.Stream, System.Windows.Markup.ParserContext)
konum: System.Windows.Application.LoadComponent(System.Uri, Boolean)
konum: System.Windows.Application.DoStartup()
konum: System.Windows.Application.<.ctor>b__1(System.Object)
konum: System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
konum: MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
konum: System.Windows.Threading.DispatcherOperation.InvokeImpl()
konum: System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
konum: System.Threading.ExecutionContext.runTryCode(System.Object)
konum: System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
konum: System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
konum: System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
konum: System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
konum: System.Windows.Threading.DispatcherOperation.Invoke()
konum: System.Windows.Threading.Dispatcher.ProcessQueue()
konum: System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
konum: MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
konum: MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
konum: System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
konum: MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
konum: System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
konum: MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
konum: MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
konum: System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
konum: System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
konum: System.Windows.Threading.Dispatcher.Run()
konum: System.Windows.Application.RunDispatcher(System.Object)
konum: System.Windows.Application.RunInternal(System.Windows.Window)
konum: System.Windows.Application.Run(System.Windows.Window)
konum: System.Windows.Application.Run()
konum: Safir.App.Main()
|
|
|
|
|
I'd guess a control or library is missing on that machine or you are trying to access some resource that is missing.
|
|
|
|
|
Thanks for reply. I thought that but the problem is how I can know which library is missing.
|
|
|
|
|
Try copying all the binaries + matching .pdbs over to the other machine. You can install WinDbg which is a very small debugger from Microsoft (just a few MBs) vs. Visual Studio and debug through there.
|
|
|
|
|
Thank you WinDbg has helped me to figure out what is missing.
|
|
|
|
|
I need a binding in SolidColorBrush color value inside my theme. So basically, instead of
<SolidColorBrush x:Key="TextBrush" Color=" #FF000000" />
I want something like -
<SolidColorBrush x:Key="TextBrush" Color="{Binding ColorVal}" />
Property could be defined something like this:
namespace ns
{
public class BindingClass
{
public Color ColorVal
{
get
{
return Color.FromRgb(255, 0, 0);
}
}
}
}
Hopefully it's possible. What should I write instead of 'Binding expression' in XAML theme?
Update:
I've got one solution-
On top,
xmlns:local="clr-namespace:ns"
Then a Resource key,
<local:BindingClass x:Key="BindingClassKey"/>
Finally binding,
<SolidColorBrush x:Key="TextBrush" Color="{Binding Source={StaticResource BindingClassKey}, Path=ColorVal}" />
Any better solution?
modified 23-Dec-11 6:19am.
|
|
|
|
|
Hi,
At present I am using an xml file to retrieve data for menu (Navigation of pages).
The xml looks like the following.
Question:
How can I make the menu to show sub menus i.e. menu within a menu?
Thanks
="1.0"="utf-8"
<Navigations>
...
<Navigation>
<item>Converter</item>
<tag>/UserControls/Converter.xaml</tag>
</Navigation>
<Navigation>
<item>Page1 view</item>
<tag>/Views/Page1.xaml</tag>
</Navigation>
<Navigation>
<item>Test Page</item>
<tag>/Views/Test.xaml</tag>
</Navigation>
...
</Navigations>
|
|
|
|
|
Just have menu levels in your xml file.
<Navigation>
<item>Converter</item>
<tag>/UserControls/Converter.xaml</tag>
<FirstLevel>
<item> sub level</item>
<tag>sub level</tag>
</FirstLevel>
</Navigation>
<Navigation>
<item>Page1 view</item>
<tag>/Views/Page1.xaml</tag>
</Navigation>
<Navigation>
<item>Test Page</item>
<tag>/Views/Test.xaml</tag>
</Navigation>
Too much of heaven can bring you underground
Heaven can always turn around
Too much of heaven, our life is all hell bound
Heaven, the kill that makes no sound
|
|
|
|
|
Yes, but how do I make it appear on the UI?
At present, I just read the item and tag of the xml file.
Does this mean that if I also read the FirstLevel element, then it will automatically show up in the UI and a sub level menu?
Thanks
|
|
|
|
|
It will not automatically show up.
Silverlight Menu[^] might give you an idea on what you would need to do to show a submenu.
|
|
|
|
|
I have a entitycollection and assigned a readonly property for each property of the entity. So that I can define whether they can be modified in Datagrid.
For example,for the same property NAME, it is allowed be be edited for some entities but others not.
But seems there is not a DataGridCell.IsReadOnly in silverlight as in WPF.
Anyone of you have met similar case ? or know that the silverlight 5 will get this supported?
|
|
|
|
|
Hi,
I am using a silverlight application which intern uses a wcf service which uses the controllers. We are following MVVM and Prism pattern.
While updating or retrieving the data, I am getting the following error. I have switched my VM machine from one domain to another domain and user name.
"The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,NTLM'"
Can anybody know why I get this error and how I can resolve it. Any kind of help or link or suggestion would help me greatly.
Thanks,
Abdul
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|