|
Nekkantidivya wrote: I want to open a new browser dynamically at run time to open a new web link.
Did you ask this before?[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi
I know probably should've posted this on the XML message boards, but no one seems to reply there.
I have a database with 3 tables; Customers, Orders, and Order Details. The relationships between the tables are set up correctly; A Customer can have many Orders and a Order can have many Order Details. I added this database via the 'Add New Data Source' wizard om Visual Studio. I then use the following line of code to create an XML document from the dataset (dsNWind2k):
dsNWind2k.Customers.WriteXml("path\\asd.xml", true);
The 'true' is for 'writeHierarchy' which specifies that it will convert the Customers table to XML as well as all it's decendants. Now this is exactly what it does, except it doesn't give me a hierarchical xml structure the way I want it to. Instead, it converts all the fields in the Customers table to XML, then directly underneath that it generates the Orders. and once again underneath the Orders, the Order Details.
Is there a way to have it generate all the Customers, then within each Customer it should display the Orders associated with that specific Customer, and then within each Order it should display the Order Details associated with that specific Order.
Here's a sample of what it does at the moment:
..more customers..<br />
..more customers..<br />
<Customers><br />
<CustomerID>NORTS</CustomerID> <br />
<CompanyName>North/South</CompanyName> <br />
<ContactName>Simon Crowther</ContactName> <br />
<ContactTitle>Sales Associate</ContactTitle> <br />
<Address>South House 300 Queensbridge</Address> <br />
<City>London</City> <br />
<PostalCode>SW7 1RZ</PostalCode> <br />
<Country>UK</Country> <br />
<Phone>(171) 555-7733</Phone> <br />
<Fax>(171) 555-2530</Fax> <br />
</Customers><br />
..more customers..<br />
..more customers..<br />
<br />
..more orders..<br />
..more orders..<br />
<Orders><br />
<OrderID>10614</OrderID> <br />
<CustomerID>BLAUS</CustomerID> <br />
<EmployeeID>8</EmployeeID> <br />
<OrderDate>1995-08-29T00:00:00+02:00</OrderDate> <br />
<RequiredDate>1995-09-26T00:00:00+02:00</RequiredDate> <br />
<ShippedDate>1995-09-01T00:00:00+02:00</ShippedDate> <br />
<ShipVia>3</ShipVia> <br />
<Freight>1.93</Freight> <br />
<ShipName>Blauer See Delikatessen</ShipName> <br />
<ShipAddress>Forsterstr. 57</ShipAddress> <br />
<ShipCity>Mannheim</ShipCity> <br />
<ShipPostalCode>68306</ShipPostalCode> <br />
<ShipCountry>Germany</ShipCountry> <br />
</Orders><br />
..more orders..<br />
..more orders..<br />
<br />
..more order details..<br />
..more order details..<br />
<Order_x0020_Details><br />
<OrderID>10599</OrderID> <br />
<ProductID>62</ProductID> <br />
<UnitPrice>49.3</UnitPrice> <br />
<Quantity>10</Quantity> <br />
<Discount>0</Discount> <br />
</Order_x0020_Details><br />
..more order details..<br />
..more order details..
This becomes a problem when I want to bind this XML to my TreeView in WPF, because now Orders and Order Details will become Parent nodes, BUT I want it to be displayed as child nodes underneath Customers
Hope someone can help me
|
|
|
|
|
Take a look at the XmlDataDocument class instead of using DataSet.WriteXml()
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Hi,
I am new to silverlight, and have a little problem!
I basically want to have a button and a textbox, and when the user presses the button it links to google and does a search on the text in the text box, so it calls
"www.google.co.uk/search?q=" + TextBoxText
The problem is when i put somthing like c# in the textbox, the # gets ignored.
Mark
|
|
|
|
|
The problem here is that your querystring text is actually malformed. C# is actually c%23 as far as a querystring goes. What you need to do is UrlEncode the text - you can use HttpUtility.UrlEncode(TextBoxText); to encode it (needs a reference to System.Web).
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Thanks
|
|
|
|
|
You are welcome.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi,
I am working on a WPF application. In this I have to set scrolling property for canvas.
If any one have any idea how to do this please reply me.
Thanks in advance.
|
|
|
|
|
Are you sure you really want to do this for a Canvas? Inherently, a Canvas has no layout characteristics and it sounds like you're laying yourself open to a whole world of hurt here. Could you not use a Grid and set the Margins of the objects on the grid as appropriate? For instance:
<ScrollViewer HorizontalScrollBarVisibility="Auto">
<Grid Background="Green">
<!-- Layout items here as appropriate -->
</Grid>
</ScrollViewer>
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
If scrolling is required, I would think a properly oriented StackPanel would be better than a Grid .
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
The interweb is abuzz today with rumors...
Silverlight 3 RTW in July!!
One such rumor[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
'Tis July 10th, not the 3rd according to my sources inside MS.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Who said the 3rd?
Maybe if I change the 3 to 3.0 it would have been easier for
you UK folks to read LOL
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Maybe if I hadn't just rolled out of bed when I read the post I might have picked up on this. I really need to start getting more than 4 hours sleep.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I added a wpf app to an existing solution, and without changing ANYTHING, I compiled it and tried to run it. I'm getting an error stating that the EXE file can't be found. Does anyone know what the hell I did to make this happen?
----------
I recreated the solution from scratch, and that seems to be the only way I could fix it. What a crock. During the discovery and resolution process, the IDE displayed an invisible modal dialog and refused to let me do anything - including closing the IDE - because the (invisible) dialog was waiting for input. I had to use task manager to close the IDE.
I hate Microsoft.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
modified on Friday, May 29, 2009 12:01 PM
|
|
|
|
|
I have a RichTextBox in my app, which is inside a control that is composed of a grid with 2 columnds,
i.e.
<Grid x:Name="LayoutRoot"
VerticalAlignment="Top" Height="Auto">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border x:Name="bdrLeft" Height="Auto"
Background="{DynamicResource SplitRichTextBoxRightSideBGBrush}"
BorderBrush="{DynamicResource SplitRichTextBoxRightSideBorderBrush}"
BorderThickness="1,1,0,1"
CornerRadius="3,0,0,3"
VerticalAlignment="Stretch">
<ContentPresenter x:Name="cpRightSide"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
Margin="0,0,0,0"
Width="Auto"
Height="Auto"
TextElement.Foreground="{DynamicResource SplitRichTextBoxLeftSideForegroundBrush}"/>
</Border>
<Border x:Name="bdrRight"
Height="Auto"
Grid.Column="1"
Background="{DynamicResource TextBoxBGBrush}"
BorderBrush="{DynamicResource TextBoxBorderBrush}"
BorderThickness="1,1,1,1"
CornerRadius="0,3,3,0"/>
<RichTextBox x:Name="rtbMain"
HorizontalAlignment="Center"
FontSize="{DynamicResource DefaultFontSize}"
Height="Auto"
BorderBrush="Transparent"
Background="Transparent"
Foreground="{DynamicResource DEFAULT_Font_Dark}"
VerticalAlignment="Center"
AcceptsReturn="False"
AcceptsTab="False"
Style="{DynamicResource ClearRichTextBoxStyle}"
Grid.Column="1"
Margin="0,3,0,3">
<localControl:EnabledFlowDocument x:Name="efdMainDocument" PageWidth="{Binding ElementName=rtbMain, Path=ActualWidth}"/>
</RichTextBox>
</Grid>
All the animations in the code are set to 00:00:00.00
However, when I add a UIElement or even text to the FlowDocument on startup, the text/uielement appear in the center of the flowdocument, then animate over to the left side where they should be. Is this a bug in WPF? I can't find anything in my code that would cause this.
|
|
|
|
|
Fixed:
Set the RichTextBox HorizontalAlignment to Stretch
|
|
|
|
|
Hi
Is there a way to populate a treeview using XML in WPF? Or by using the .xsd file?
If yes, please give me advice on how to get started. I've tried binding the treeview to the database using Hierarchical Datatemplates etc. but that still does not do the trick if you want multiple children nodes.
|
|
|
|
|
How about a short sample of the XML you're working with along with
how you're trying to bind to that XML...
Is the XML data actually hierarchical?
Also, searching on "wpf treeview xml data binding" yields tons of examples.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
The thing is, I don't have a XML structure yet, I'm using a typed dataset which was generated for me by adding a datasource via the Visual Studio wizard, so I first have to generate a XML file from my typed dataset, and then bind it to the treeview. Here's a sample of what it might look like though:
<?xml version="1.0" standalone="yes" ?>
- <NewDataSet>
- <Products>
<ProductID>1</ProductID>
<ProductName>Chai</ProductName>
<SupplierID>1</SupplierID>
<CategoryID>1</CategoryID>
<QuantityPerUnit>10 boxes x 20 bags</QuantityPerUnit>
<UnitPrice>18</UnitPrice>
<UnitsInStock>39</UnitsInStock>
<UnitsOnOrder>0</UnitsOnOrder>
<ReorderLevel>10</ReorderLevel>
<Discontinued>false</Discontinued>
</Products>
- <Products>
<ProductID>2</ProductID>
<ProductName>Chang</ProductName>
<SupplierID>1</SupplierID>
<CategoryID>1</CategoryID>
<QuantityPerUnit>24 - 12 oz bottles</QuantityPerUnit>
<UnitPrice>19</UnitPrice>
<UnitsInStock>17</UnitsInStock>
<UnitsOnOrder>40</UnitsOnOrder>
<ReorderLevel>25</ReorderLevel>
<Discontinued>false</Discontinued>
</Products>
</NewDataSet>
This is obviously just a basic table showing some Products, the database I'm going to be using will have sub levels as well e.g. A Product(above) can have multple Parts assoiciated with it, so that needs to be shown within Product and for each Product
|
|
|
|
|
What I also want to know, is say for instance you have 2 tables; Categories and Products. And the relationship between them is one-to-many (A category can have many products). Is it possible to generate an XML file showing all the different categories as well as the products belonging to them hierarchically?
<Category id=1><br />
<Product id=1><br />
<name>milk</name><br />
<description>white</description><br />
<price>3.00</price><br />
<Product id=2><br />
<name>cola&/name><br />
<description>black&/description><br />
<price>3.00&/price><br />
<Category id=2><br />
<Category id=3>
|
|
|
|
|
The UI part is relatively easy - here's an example (not I've added some
Parts to the Products so there would be some hierarchical data):
<Window x:Class="WPFTester.Window2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window2" Width="300" Height="250" >
<Window.Resources>
<XmlDataProvider x:Key="ProductData" XPath="*">
<x:XData>
<NewDataSet xmlns="" >
<Products>
<ProductID>1</ProductID>
<ProductName>Chai</ProductName>
<SupplierID>1</SupplierID>
<CategoryID>1</CategoryID>
<QuantityPerUnit>10 boxes x 20 bags</QuantityPerUnit>
<UnitPrice>18</UnitPrice>
<UnitsInStock>39</UnitsInStock>
<UnitsOnOrder>0</UnitsOnOrder>
<ReorderLevel>10</ReorderLevel>
<Discontinued>false</Discontinued>
<Parts>
<PartName>Part 1</PartName>
</Parts>
<Parts>
<PartName>Part 2</PartName>
</Parts>
<Parts>
<PartName>Part 3</PartName>
</Parts>
</Products>
<Products>
<ProductID>2</ProductID>
<ProductName>Chang</ProductName>
<SupplierID>1</SupplierID>
<CategoryID>1</CategoryID>
<QuantityPerUnit>24 - 12 oz bottles</QuantityPerUnit>
<UnitPrice>19</UnitPrice>
<UnitsInStock>17</UnitsInStock>
<UnitsOnOrder>40</UnitsOnOrder>
<ReorderLevel>25</ReorderLevel>
<Discontinued>false</Discontinued>
<Parts>
<PartName>Part 1</PartName>
</Parts>
<Parts>
<PartName>Part 2</PartName>
</Parts>
<Parts>
<PartName>Part 3</PartName>
</Parts>
</Products>
</NewDataSet>
</x:XData>
</XmlDataProvider>
<HierarchicalDataTemplate DataType="Products" ItemsSource="{Binding XPath=Parts}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding XPath=ProductID}" Margin="0,0,6,0" />
<TextBlock Text="{Binding XPath=ProductName}" />
</StackPanel>
</HierarchicalDataTemplate>
<DataTemplate DataType="Parts" >
<TextBlock Text="{Binding XPath=PartName}" />
</DataTemplate>
</Window.Resources>
<Grid >
<TreeView ItemsSource="{Binding Source={StaticResource ProductData}, XPath=*}" />
</Grid>
</Window>
In real life your XML data is dynamic, but you can bind to dynamically created XML,
for example: How to: Bind to XDocument, XElement, or LINQ for XML Query Results[^]
Creating the XML is outside the scope of this message board, but if you're
relatively new at it, I'd really recommend learning a bit of LINQ.
Using LINQ to XML and possibly LINQ to Dataset you'll have a consistent way to work with
both Dataset and XML data. For example, you can use LINQ to query a multi-table
dataset and build a hierarchical XML representation for presentation.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks I will have a look at LINQ. That sounds like it might do the trick.
So I guess there is no easy way to create a hierarchical XML structure based on a multi-table dataset. I though there might have been.
|
|
|
|
|
I just found out that when you're using untyped datasets, then you can manually set up a relation between your tables, and then you just set the Relation's Nested property to true, then when you generate an XML file it creates a beautiful hierarchical structure, just the way I want it.
BUT, I'm using a typed dataset, which means the relations are created for me. Is there a way to manually edit these relations?
|
|
|
|