|
Christian Graus wrote: Shouldn't that style then be a template, so it gets reused ?
That exercise is left to the reader
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
To use the default Separator style, remove the StatusBarItem
wrappers from the Separators:
<StatusBar Grid.Row="1"
DockPanel.Dock="Bottom"
Height="23"
VerticalAlignment="Bottom"
BorderBrush="Black"
BorderThickness="0,.5,0,0" >
<StatusBar.ItemsPanel>
<ItemsPanelTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
</Grid>
</ItemsPanelTemplate>
</StatusBar.ItemsPanel>
<StatusBarItem Grid.Column="0" >
<TextBlock Text="TextBlock 1" Name="statusBarHelp" />
</StatusBarItem>
<Separator Grid.Column="1" />
<StatusBarItem Grid.Column="2" HorizontalContentAlignment="Center" >
<TextBlock Text="TextBlock 2" Name="statusBarFullPath" />
</StatusBarItem>
<Separator Grid.Column="3" />
<StatusBarItem Grid.Column="4" >
<TextBlock Text="TextBlock 3" Name="imageCount" />
</StatusBarItem>
</StatusBar>
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Okay, now we're talking. Good answer. Thanks, Mark. Looks good. I just make them invisible when the middle TextBlock is empty. Sure was a lot of screwing around for a lousy pair of Separator elements.
|
|
|
|
|
Hi,
I am working on a WPF application. In this I need to find the temporary drives created i.e., like drives created when some mobile or pen drive are created. From this Temporary drive created I need to get the image files.
If any one have any idea to get the names or path of the temparory drives created please reply me.
Thanks in advance.
|
|
|
|
|
|
|
Please don't create a new account. You're the only person on EARTH who thinks it's wise to mix a 'browser application' ( i.e. you will put a web browser control in a window ), with a database.
CBenac wrote: Data Source=TOSHIBA_PC\SQLEXPRESS
Is this your local machine ? Have you tried logging in with a username and password ? Have you googled the error message to see possible solutions ?
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
|
A WPF browser application runs in the browser ? I would assume that the issue is the application being sandboxed then.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
I'm sorry if I misunderstood you at first, someone else has been posting about a browser application in WPF, and asking the same thing for days. I am trying to help you here, there's no need to delete your posts, or feel unwelcome. I am sorry for the misunderstanding, I do suspect that you're saying the app is running inside your browser, and that sandboxing is why you can't access a local DB, but you can probably access a network one. Have you had any luck with that avenue ?
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
There is a sample application that uses the DataGrid (from the WPF Toolkit) and displays the customers table from the NorthWind database. It runs fine if it is created as an EXE which is the original intention of the author. However, since I need the application to run in the browser, I recreate the same project as a XPAP but the browser displays the bellow error message (snipet) from the "More information" link. It appears to be a connection issue with the database. I'm using Windows authentication mode.
>>
..
The action that failed was:
Demand
The type of the first permission that failed was:
System.Data.SqlClient.SqlClientPermission
The first permission that failed was:
<IPermission class="System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
AllowBlankPassword="False">
<add ConnectionString="Data Source=TOSHIBA_PC\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True"
KeyRestrictions=""
KeyRestrictionBehavior="AllowOnly"/>
</IPermission>
.....
>>
The sample code was retrieved from here:
http://www.codeproject.com/KB/WPF/WPFDataGridExamples.aspx
|
|
|
|
|
OK - well, if you're in the browser, then I assume you're serving your app over the web. You're going to need a connection string that connects to a remote machine, not one that relies on Windows security, because the browser is sandboxed from the rest of the machine. It's basically the security in the browser that is hitting you. Have you tried using a username/password to connect to the DB ?
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
I changed from Windows to SQL Server authentication and logged as User: sa and the password, but it didn't make any difference. I'll look into this remote machine you mentioned. But any additional sugestion is welcomed. It is surprise to me the few online documentation regarding WPF.
Thanks so far for your input.
|
|
|
|
|
Christian,
I changed the properties of the application to "Full trusted site" and it worked nicely
Thanks for your help
CBenac
|
|
|
|
|
You need to remember the size of the image itself, then you need to calculate the size of the canvas and work out a ratio to calculate a pixel position. If the aspect ratio is different, you need to work out if you use the width or the height to calculate position, and if you did any centring of the image, you need to calculate that offset, too.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Welcome to hell. Width is the one you can set, but ActualWidth is the one that contains the width of the control. I believe the idea is, you can set what width you want, but you're not necessarily going to get it. I've had trouble, for example, placing an image in a grid. If they grid has no explicit size, even if it's told to stretch itself, you can put a BitmapImage in the Image, you can even set the Width of the Image, and the Height, but ActualWidth will stay zero.
ActualWidth is the one that you always use to know what the Width is.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Glad to help.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
This shouldn't be a "bumpy ride" if you understand how WPF layout works.
"There is a difference between the properties of Height and Width and
ActualHeight and ActualWidth. For example, the ActualHeight property is
a calculated value based on other height inputs and the layout system.
The value is set by the layout system itself, based on an actual rendering
pass, and may therefore lag slightly behind the set value of properties
such as Height that are the basis of the input change.
Because ActualHeight is a calculated value, you should be aware that
there could be multiple or incremental reported changes to it as a result
of various operations by the layout system. The layout system may be
calculating required measure space for child elements, constraints by
the parent element, and so on."
WPF: The Layout System[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
The goal is to remember the position of a GridSplitter from one execution of a window to the next so I can restore the previous position when the window reloads.
For purposes of discussion, assume my GridSplitter is vertical. I remember reading somewhere that to remember the position of the GridSplitter all you have to do is remember the width of the left element and when the window loads, set the element to that width.
However, my SizeChanged event for the left element only happens when the window is first loaded. Dragging the position of the splitter (hence changing the size of the left element - as well as the right element) does not generate any more SizeChanged events for the left element. That seems totally illogical.
Here is something else that seems totally illogical. I also tried getting MouseUp and MouseLeftButtonUp events for both the splitter and the Grid element the splitter is in, and I don't get any of these events either!
What could possibly be going on? The element that is in the left column of the Grid is a TreeView and I haven't even started populating it yet.
|
|
|
|
|
I searched the Code Project for the answer to this question and couldn't find one. I also Googled for it and found several proposed and confusing answers that I couldn't make much sense of. People don't seem to be very clear about what they really want. So I thought I'd ask the question on this Code Project WPF forum, but in the meantime I kept working on an answer myself. After trying a bunch of possibilities for a couple hours, I got the idea of remembering the width of the ColumnDefinition rather than the width of the element contained in the column. By itself, the latter doesn't work, but it does in conjunection with the former, depending on what you actually want to do. After receiving some success using the column definition, I ran into other problems, stemming from the fuzzy idea I had about the actual behavior I wanted. Eventually I defined that as follows, which may not be what you want:
Before my change, the position of my GridSplitter was automatically set to 1/3 the width of the grid and changing the width of the containing window maintained this 1/3 proportional ratio. I decided that for my application, this was undesirable behavior. I wanted the width of the left panel to remain fixed as the width of the window changed, and I wanted only the width of the right panel to change as I manually changed the width of the window. This required defining my grid columns as follows:
<Grid.ColumnDefinitions>
<ColumnDefinition Name="treeColumn" Width="0"/>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
The middle column corresponds to the GridSplitter. The width of the left column is set to 0 in this markup because that is actually the property I want to set programmatically in code-behind, both when the window is loaded and when the user drags the GridSplitter.
The only thing I had to work out is that the Width property of a ColumnDefinition is a GridLength object, not a simple double.
The other thing I had to figure out is what event to look for. I already explained in my initial post that SizeChanged on the element in the left column didn't work, and neither did MouseLeftButtonUp. I wasn't getting either event. That's because these are bubbling events that are being handled by higher level controls. I needed a tunneling event, a Preview event. For my purposes, PreviewMouseLeftButtonUp on the GridSplitter did the trick. Here is that event from my code-behind:
private void mainSplitter_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
State.TreeWidth = treeColumn.Width.Value;
treeCtrl.Width = frameForPages.Width - 16;
}
(The hard-coded 16 is a kludge: the hard-coded width of the left and right border. I'll clean this up later.) Now all I needed was the code to set the initial width of left column (treeControl) when my application started:
treeColumn.Width = new GridLength(State.TreeWidth);
treeCtrl.Width = frameForPages.Width - 16;
So now I know how to save the position of the GridSplitter from one invocation of its window to the next, and the next time someone searches for the answer to this question, hopefully he'll run into this post and see what some of the issues are that need to be addressed to accomplish the behavior he wants.
modified on Friday, October 30, 2009 12:12 PM
|
|
|
|
|
fjparisIII wrote: Either I'm trying to do things that nobody knows the answer to or my questions are so stupid that people just laugh when they see them.
The traffic in this forum is pretty slow. However, there's a few people who are very good at WPF, and then there's me, who is doing his best. We'd all answer you, given a chance. Timezones mean you may need to wait a day.
You should use ActualWidth if it exists, rather than width. The preview events always fire, but the non preview events may not fire if something further up the tree consumes the event. Upshot is, I typically use the preview events only.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Christian Graus wrote: You should use ActualWidth if it exists, rather than width.
ColumnDefinition.Width is not the same as UIElement.Width. The latter is a double, the former is a GridLength and doesn't work the same way as a UIElement.Width. You can't use ActualWidth to solve this problem.
Christian Graus wrote: The preview events always fire, but the non preview events may not fire if something further up the tree consumes the event. Upshot is, I typically use the preview events only.
As I explained above, this is because a tunneling event is needed here, i.e. a Preview event.
|
|
|
|
|
fjparisIII wrote: BTW, I never did get my answer on how to save a lossless rotation of a JPEG. This may be impossible with WPF (you probably could do it in that nightmarish WIC). Looks like I'm going to have to stoop to using the GDI+ .NET classes.
Well, if you read my blog, http://thingsihateaboutmicrosoft.blogspot.com/2009/06/wpf-destroys-images-when-resizing-them.html[^], I started my blog b/c you reminded me of that WPF resizing image bug. If they can't fix that, they are not going to add the sort of thing you wanted to do....
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
If I define a namespace (xmlns) in app.xaml, does the whole application assembly see it, or do I have to redefine it in each xaml file from which I wish to use it?
"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
|
|
|
|
|
No. An XML namespaces binding scope is limited to the tag where they were defined[^]. I don't know whether XAML is XML v1.0 or v1.1 but a namespace binding attribute value cannot be empty.
And the first binding up the tree from where you use it is the one applied.
<StackPanel>
<Grid xmlns:sys="clr-namespace:System;assembly=mscorlib">
<Grid.Resources>
<sys:Int32 x:Key="i">
6
</sys:Int32>
</Grid.Resources>
</Grid> <!-- mscorelib binding scope ends here -->
<Grid xmlns:sys="clr-namespace:System;assembly=System">
<Grid.Resources>
<sys:Uri x:Key="uri">
http:
</sys:Uri>
</Grid.Resources>
<Grid xmlns:sys="clr-namespace:System;assembly=mscorlib">
<Grid.Resources>
<sys:Byte x:Key="b"> <!-- The binding used is mscorlib's -->
8
</sys:Byte>
</Grid.Resources>
</Grid>
</Grid>
</StackPanel>
There seems to be a problem displaying the code. Solved, the encode HTML option was disabled
Eslam Afifi
modified on Friday, June 19, 2009 12:50 PM
|
|
|
|
|