|
Got bored with the MS Access - here's a real simple example...
The temnplate tells it how to display. THe vm has an Options property containing a collection of Option - each of which has an OptionName property
<base:BaseView.Resources>
<DataTemplate x:Key="ButtonTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
</Grid.ColumnDefinitions>
<Button Content="{Binding OptionName}" Height="32"/>
</Grid>
</DataTemplate>
</base:BaseView.Resources>
<StackPanel Background="#FFFF00" Height="150">
<ItemsControl ItemsSource="{Binding Options}"
ItemTemplate="{StaticResource ButtonTemplate}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" HorizontalAlignment="Center" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</StackPanel>
Hope that's enough to get you started - you need to work out how you're going to handle clicks, of course... each button may bind to the same command with a varying parameter, or each to its own command - I haven't done this bit (back to the MS Access now!)
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
Hi
I'm trying to modify an Xml file. This is the content of the Xml. The problem is that after changes, it will creates a copy of the content of the Xml file without changing the old content.
Before changes :
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="Application.Properties.Settings.DBConnectionString"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DB.mdb"
providerName="System.Data.OleDb" />
</connectionStrings>
</configuration>
After changes :
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="Application.Properties.Settings.DBConnectionString"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DB.mdb"
providerName="System.Data.OleDb" />
</connectionStrings>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="Application.Properties.Settings.DBConnectionString"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DataBase\DB.mdb"
providerName="System.Data.OleDb" />
</connectionStrings>
</configuration>
The code is :
System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
FileStream reader = new FileStream(this._XmlFilePath, FileMode.Open, FileAccess.ReadWrite);
xdoc.XmlResolver = null;
xdoc.Load(reader);
System.Xml.XmlElement Node = (System.Xml.XmlElement)xdoc.DocumentElement.SelectSingleNode("//configuration/connectionStrings/add[@name=\"Application.Properties.Settings.DBConnectionString\"]");
if (Node != null)
{
Node.Attributes.GetNamedItem("Source").Value = "C:\DataDabe\DB.mdb";
xdoc.Save(reader);
reader.Close();
}
"For as long as men massacre animals, they will kill each other. Indeed, he who sows the seed of murder and pain cannot reap joy and love." Pythagoras
|
|
|
|
|
Nope. I don't see what this has to do with WPF or Silverlight. Wrong forum I'm afraid.
|
|
|
|
|
Check out the ConfigurationManager class. It looks like you are trying to edit the app.config file and this would be a better approach.
"You get that on the big jobs."
|
|
|
|
|
You've got the wrong forum unfortunately.
This is the XAML forum and not the XML forum.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
|
|
|
|
|
Oh sorry..this was an Window form application...wrong forum
sorry again
bye
"For as long as men massacre animals, they will kill each other. Indeed, he who sows the seed of murder and pain cannot reap joy and love." Pythagoras
|
|
|
|
|
I have populated a combo box as follows:
<ComboBox Height="23" HorizontalAlignment="Left" Margin="120,6,0,0"
Name="cboHealth" SelectedIndex="{Binding Path=HealthLevelID}"
VerticalAlignment="Top" Width="256" />
private void PopulateHealthLevels()
{
List<clsDetails> healthlevels = new List<clsDetails>();
healthlevels = clsAccess.GetHealthLevels();
foreach (clsDetails details in healthlevels)
{
cboHealth.Items.Add(details.HealthLevelName);
}
}
The datatable returns the HealthLevelID field as well as otherr fields.
HealthLevelID has values of 1 and 2 for Normal and unNormal respectively.
The combo box does get populated but it does not show the correct item for the selected row.
What am I doing wrong please?
Thanks
|
|
|
|
|
A couple of things here.
1. Your title needs some work. Simply stating wpf is not enough.
2. The code should be enclosed in pre tags.
Now, your problem lies in the fact that SelectedIndex is actually zero based, so your values will not match. SelectedIndex should only be used to indicate the relative position of the object in your collection.
|
|
|
|
|
Hi,
At present the HealthLevelID has only values 1 or 2 in it's tblHealthlevels table.
Do you mean that since I am using selectedindex in xamml, I can change the integer values in the sql server table to be 0 and 1 instead of 1 and 2 and then it will work? If so, what if I add more values in the table such as 1, 2, 3, 4, ...
Will my existing xaml work ok?
Thanks
|
|
|
|
|
I did do what you mentioned but still unable to solve this issue.
Any thoughts please?
|
|
|
|
|
Rather than relying on the selected index, I prefer to use a selected item.
|
|
|
|
|
Still have the same problem.
|
|
|
|
|
Seems that ComboBox doesnt know that HealthLevelID was changed, try this:
BindingExpression binding = BindingOperations.GetBindingExpression(cboHealth, ComboBox.SelectedIndexProperty);
if (binding != null)
{
binding.UpdateTarget();
}
Also, make sure that HealthLevelID is public
modified on Thursday, February 3, 2011 6:35 AM
|
|
|
|
|
You're missing Mode=TwoWay from your binding expression (assuming it's the same in WPF as Silverlight)
C# has already designed away most of the tedium of C++.
|
|
|
|
|
Good Day All
I have a Policy file in the Root of my wwwRoot. and i have place it in the Folders of the indivisuall services, but i get a warning that says
Warning 1 Could not locate cross-domain policy at 'vuyiswa-pc': Web services might not be accessible at runtime by your Silverlight application. For more details please contact the web server administrator or press F1 after selecting this warning 0 0
and this make my app to fail with the cross domain Error
An error occurred while trying to make a request to URI 'http://localhost/BLLBusiness/BLLService.svc'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.
Does any have an Idea ?
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Using a wire sniffer tool like Fiddler, check if the file is actually downloaded to the client.
If no, then I guess the location of the file is incorrect.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
|
|
|
|
|
Good Day Abhi
Thanks for your reply, it is not easy to find a problem in this situation. even Fiddler pointed out nothing. so what i did to resolve this is that i have change the application Pool to .net 4 Classic and it started to work, i could see the policy files via the local-host uri.
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Hi All,
I want Database Connectivity in my Silverlight Web Application without using WCF service. Is is possible?
I have googled but no luck.
Thank U,
Sunil G.
|
|
|
|
|
Hi Sunil,
When you want to use Silverlight for Web Developement and at the same time want to communicate with the database then you only have the option of service, whether Web Service of WCF Service.
But why don't you want to use WCF..?
|
|
|
|
|
|
No. Its not possible in silverlight. Silverlight runs client side and it cannot make server side calls.
|
|
|
|
|
Sorry, but it is possible to have a local client side database. There are a number of projects which aim to provide this functionality via Isolated Storage. Here's[^] one such example.
|
|
|
|
|
Well i don't think its no a problem to achieve that , but its not a good way to go. I have some Silverlight Apps that Connects to the Database without using WCF , i am just using pure OOP , but these are very small apps, the way to go is RIA. You need to use WCF Services its much easier like that.
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Hi
Looking for a user control which can display HTML in a string variable (not a url, not a html document saved on a disk so WebBrowser control won't do it)
Is there one?
Thanks
dev
|
|
|
|
|
WebBrowserControl has a NavigateToString [^]method - can you not use that?
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|