|
Didn't this get an answer the other day ? Handle the form closing event and the event args will tell you what caused the form to close.
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've been trying for an hour and can't get them to show up. I want three TextBlock fields in the StatusBar, each separated by a Separator. The TextBlock fields show up fine. I want the middle field to to be centered and take up all the space that the left and right fields do not, and my XAML does achieve this. Here is that XAML. I tried an explicit width of 10 for the two Separator elements, but that didn't make a difference. What am I doing wrong?
<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
Name="statusBarHelp"
>
</TextBlock>
</StatusBarItem>
<StatusBarItem
Grid.Column="1"
>
<Separator></Separator>
</StatusBarItem>
<StatusBarItem
Grid.Column="2"
HorizontalContentAlignment="Center"
>
<TextBlock
Name="statusBarFullPath"
>
</TextBlock>
</StatusBarItem>
<StatusBarItem
Grid.Column="3"
>
<Separator></Separator>
</StatusBarItem>
<StatusBarItem
Grid.Column="4"
>
<TextBlock
Name="imageCount"
Padding="0,0,10,0"
>
</TextBlock>
</StatusBarItem>
</StatusBar>
|
|
|
|
|
If you want seperators, why not add them as a border on the controls, you can specify different widths for the border, so put 10,0 on the middle one to get 10 on each side. Otherwise, I expect you'd need to specify widths on the seperator itself, and specify a width of 10 on your column definition.
WPF is a PITA, it's way too hard to get stuff to appear at the size you asked for.
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: If you want seperators, why not add them as a border on the controls
Borders on the controls are a last resort possibility, but my question was, why don't the Separator elements show up? I shouldn't have to specify a width on them, as their constructor should specify a default width. In no other code I've ever seen do you have to specify a width for a Separator.
But I experimented by setting a width and was shocked to discover that the Separator in a StatusBar is a horizontal line, not a vertical line as one should expect. One should expect that, right? I suppose a horizontal line will work, but I wonder who's brilliant idea it was at Microsoft to make a Separator a horizontal line in a WPF StatusBar? Isn't that totally nonstandard? You'd expect horizontal lines only between items arranged vertically, like the separators between menu items.
Christian Graus wrote: I expect you'd need to specify widths on the seperator itself, and specify a width of 10 on your column definition.
I tried an explicit width on the column definition and it didn't work, so went back to Width="Auto" . When I specified a width on the separator itself, that's when I discovered the very strange thing that the Microsoft developer has done, in making separators horizontal lines in status bars instead of vertical lines. This almost seems like a bug to me. I should just put a vertical bar in there.
|
|
|
|
|
fjparisIII wrote: I wonder who's brilliant idea it was at Microsoft to make a Separator a horizontal line in a WPF StatusBar?
It isn't. It's orientation is based on the ItemsControl it is used as an item in.
You didn't use them as ItemsControl items so you got the default horizontal
orientation.
See my other replies for two ways you can use the separators in a more correct fashion.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I took the Separator elements out. Those horizontal lines just look like a kludge.
|
|
|
|
|
fjparisIII wrote: I took the Separator elements out.
Why would you take the separator elements out if you want separators?
I gave you two working examples - one that you can totally customize
the style of the separators, and another that uses the default style.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: Why would you take the separator elements out if you want separators?
I gave you two working examples - one that you can totally customize
the style of the separators, and another that uses the default style.
I took them out before I saw your examples. After I saw your second example, I put them back in. Now they look great. Thanks for your attention.
|
|
|
|
|
*Edit*
With your Separators wrapped in StatusBarItem, they default to a horizontal orientation, so
you'd need to give your separators a vertically oriented style, otherwise you can't see them...
<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>
<StatusBarItem Grid.Column="1" >
<Separator >
<Separator.Style>
<Style TargetType="{x:Type Separator}">
<Setter Property="Height" Value="20"/>
<Setter Property="Margin" Value="2,0,2,0"/>
<Setter Property="Focusable" Value="false"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Separator}">
<Border BorderBrush="LightSlateGray" BorderThickness="1"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Separator.Style>
</Separator>
</StatusBarItem>
<StatusBarItem Grid.Column="2" HorizontalContentAlignment="Center" >
<TextBlock Text="TextBlock 2" Name="statusBarFullPath" />
</StatusBarItem>
<StatusBarItem Grid.Column="3" >
<Separator >
<Separator.Style>
<Style TargetType="{x:Type Separator}">
<Setter Property="Height" Value="20"/>
<Setter Property="Margin" Value="2,0,2,0"/>
<Setter Property="Focusable" Value="false"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Separator}">
<Border BorderBrush="LightSlateGray" BorderThickness="1"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Separator.Style>
</Separator>
</StatusBarItem>
<StatusBarItem Grid.Column="4" >
<TextBlock Text="TextBlock 3" Name="imageCount" />
</StatusBarItem>
</StatusBar>
In my second reply is a simpler version with the StatusBarItem wrappers removed.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
modified on Sunday, June 21, 2009 5:06 PM
|
|
|
|
|
Shouldn't that style then be a template, so it gets reused ? :P
OK, so a seperator is invisible without a style ? I've never used one, so I had no idea about that.
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: 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
|
|
|
|