|
Thanks for the reply. I finally got it working. I had to update the web.config to use Windows auth and impersonate the user with db access. However I now need to figure out how to handle exceptions in silver light pages.
I didn't get any requirements for the signature
|
|
|
|
|
ToddHileHoffer wrote: I now need to figure out how to handle exceptions in silver light pages.
Same way you would anywhere?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
No, not at all. I have an error handler class for ASP.Net applications. The class is called from the global Application_Error event. The error handler gathers a ton of information by iterating the child exceptions, using reflection and iterating form collection and session values. The handler class then writes out all this information to a file and emails me the information as well.
I don't know of a global error event in a silverlight. Also, a silver light app can not send email, nor can it write out a file on my server. So no the error handling is not the same at all compared to ASP.Net.
I didn't get any requirements for the signature
|
|
|
|
|
Heh - you just stated "how to handle exceptions in silver
light pages"
ToddHileHoffer wrote: I don't know of a global error event in a silverlight
Perhaps Application.UnhandledException Event[^]
ToddHileHoffer wrote: Also, a silver light app can not send email, nor can it write out a file on my server.
Of course not. This is not ASP.NET. Silverlight is
completely client side, running within the confines
of a browser security sandbox, and using a different
version of the .NET framework.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello ,
I have a desktop application built in WPF and i want to integrate Windows Live authentication + communication . That is , users can use the application by signing in with their live id and interract with their contacts by sharing some data in the application . I found a Web API for this , but I have a desktop application . Can anyone point me some information about how (if possible) can i do this ? Thank you !
|
|
|
|
|
|
In our application we have to implement a keyboard buffer.
The current version is WinForms. You can catch the keystroke in regular events and use a sendmessage to control (Textboxes most of the time).
WPF-Textboxes aren't based on the WIN32 edit controls.
Does a sendmessage here work too, or are there even better possibilities to send / emulate a keystroke.
|
|
|
|
|
I think that WPF UI Automation[^] should help.
But I haven't used it personally, so I'm not sure...
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Hi
I want to develop a game like Scrabble in WPF for which I need some suggestions
For Visuals:
1. What controls can be utilized to represent a (let's say 9 x 9) matrix? I would need ability to associate each cell with an id to know its state at all times during execution.
2. How can I inject different visual properties to a cell of matrix?
3. Would I need something like separate layers for base board, and tiles?
For logic:
4. How to go about validating a word and possible words around it?
Please advise. Thanks
PJ
Follow your goals, Means will follow you ---Gandhi---
|
|
|
|
|
mittalpa wrote: 1. What controls can be utilized to represent a (let's say 9 x 9) matrix? I would need ability to associate each cell with an id to know its state at all times during execution.
You could use a simple grid for this. I wouldn't worry about associating the cell with an id to know its state - keep track of this with your model instead. It's a much better mechanism for this as you can use binding to keep associate it with the visuals.
You've already worked out that you are going to use a matrix, so you know that you can just represent the word on the board with the matrix.
"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
|
|
|
|
|
mittalpa wrote: 1. What controls can be utilized to represent a (let's say 9 x 9) matrix? I would need ability to associate each cell with an id to know its state at all times during execution.
Like the other guy said, use a Grid (or DataGrid or ListView or a custom control) and modify your view model when dealing with state.
mittalpa wrote: 2. How can I inject different visual properties to a cell of matrix?
Use properties on your view model to determine what your view displays. WPF is rich with ways of dealing with what to display, such as template selectors.
mittalpa wrote: 3. Would I need something like separate layers for base board, and tiles?
WPF allows you to layer things easily. However, you wouldn't necessarily NEED to layer... might make some things easier though.
mittalpa wrote: 4. How to go about validating a word and possible words around it?
There are word lists you can download for free. There is one from an old version of a dictionary (1916 Merriam Webster?), for example, that you could download, parse, and use when validating that the words used are valid. You could also create a web crawler to find words on the Internet... and you could allow users to enter their own words. As far as the validation logic itself, just focus on the view model rather than the view.
|
|
|
|
|
Hi,
I know DataContext is a DependencyProperty and I know how to use DataContext in DataBiding in WPF but I don't know what DataContext is ?
i.e : DataContext is some spaces in memory that we can use it for DataBinding , Is it true ?
I google , but I couldn't find anything useful !
Would you please explain it ?
Thanks.
|
|
|
|
|
MSDN [^] - Data context is a concept that allows elements to inherit information from their parent elements about the data source that is used for binding, as well as other characteristics of the binding, such as the path.
Nice question - made me stop and think .
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
Got it, thanks
|
|
|
|
|
Does WPF have the same restriction as Windows Forms that you can't make cross-thread calls on UI controls?
|
|
|
|
|
Yes, it does. You have to call Invoke or BeginInvoke of the Dispatcher of the UI thread. See the remarks here[^]
Eslam Afifi
|
|
|
|
|
Hi all,
I've been trying to achieve this using some samples from the net but with no luck.
I need my main window to display X number of circular panels, each with it's own back color and text inside.
Using some examples from the net I created a list box with wrap panel as data template which allowed me have the panels as items in the list box.
Now I need to create an item template for the panels but I cant find a good way to do so + having the text fit the circle.
Additionally, I'd appreciate if you could tell me how to disable the selection in the list box so user can't select the panels.
Thanks,
darthBug
Join the dark side of the code
|
|
|
|
|
The ListBox inheritence tree is:
ListBox -> Selector -> ItemsControl ->...
If you don't want a selction, use the ItemsControl in your xaml.
An example can be found in MSDN at:
ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/fxref_presentationframework/html/983ce3de-dcc4-f2f3-95ba-906d2c28716b.htm
Unfortunately, the online ItemsControl documentation does not include the example XAML and in case your MSDN installation don't include it I'll paste it below.
For other xaml examples of other controls, you can reference:
http://msdn.microsoft.com/en-us/library/aa970773.aspx[^]
From MSDN Library:
<ItemsControl Margin="10"
ItemsSource="{Binding Source={StaticResource myTodoList}}">
<!--The ItemsControl has no default visual appearance.
Use the Template property to specify a ControlTemplate to define
the appearance of an ItemsControl. The ItemsPresenter uses the specified
ItemsPanelTemplate (see below) to layout the items. If an
ItemsPanelTemplate is not specified, the default is used. (For ItemsControl,
the default is an ItemsPanelTemplate that specifies a StackPanel.-->
<ItemsControl.Template>
<ControlTemplate TargetType="ItemsControl">
<Border BorderBrush="Aqua" BorderThickness="1" CornerRadius="15">
<ItemsPresenter/>
</Border>
</ControlTemplate>
</ItemsControl.Template>
<!--Use the ItemsPanel property to specify an ItemsPanelTemplate
that defines the panel that is used to hold the generated items.
In other words, use this property if you want to affect
how the items are laid out.-->
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<!--Use the ItemTemplate to set a DataTemplate to define
the visualization of the data objects. This DataTemplate
specifies that each data object appears with the Proriity
and TaskName on top of a silver ellipse.-->
<ItemsControl.ItemTemplate>
<DataTemplate>
<DataTemplate.Resources>
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="18"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
</DataTemplate.Resources>
<Grid>
<Ellipse Fill="Silver"/>
<StackPanel>
<TextBlock Margin="3,3,3,0"
Text="{Binding Path=Priority}"/>
<TextBlock Margin="3,0,3,7"
Text="{Binding Path=TaskName}"/>
</StackPanel>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
<!--Use the ItemContainerStyle property to specify the appearance
of the element that contains the data. This ItemContainerStyle
gives each item container a margin and a width. There is also
a trigger that sets a tooltip that shows the description of
the data object when the mouse hovers over the item container.-->
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="Control.Width" Value="100"/>
<Setter Property="Control.Margin" Value="5"/>
<Style.Triggers>
<Trigger Property="Control.IsMouseOver" Value="True">
<Setter Property="Control.ToolTip"
Value="{Binding RelativeSource={x:Static RelativeSource.Self},
Path=Content.Description}"/>
</Trigger>
</Style.Triggers>
</Style>
</ItemsControl.ItemContainerStyle>
</ItemsControl>
|
|
|
|
|
Given the following xaml:
<ListBox
Name="listBox"
BorderThickness="0"
SelectionMode="Extended"
KeyUp="listBox_KeyUp"
SelectionChanged="listBox_SelectionChanged"
>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel
Name="wrapPanel"
MinHeight="17"
Width="444"
IsItemsHost="True"
Orientation="Horizontal"
HorizontalAlignment="Left"
>
</WrapPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
How do I dynamically size the width of the WrapPanel? The name of the WrapPanel ("wrapPanel") does not seem to be available from code behind. Also, the following code returns null:
Object o = listBox.FindName("wrapPanel");
The following line throws a "file not found" exception:
Object o = listBox.ItemsPanel.FindName("wrapPanel", listBox);
What I want to do is keep the width of the WrapPanel in step with changes to the width of the ListBox. As you can see, right now it's hard-coded as 444, which is the width of the ListBox when the dialog first comes up, but as the user drags the left or right border of the containing resizable window, the ListBox width changes but the WrapPanel is locked at 444. Somehow I need to get ahold of the WrapPanel object.
|
|
|
|
|
You can bind the width (or height if wrapping the other way) to the corresponding property in the ScrollContentPresenter
<WrapPanel
Name="wrapPanel"
MinHeight="17"
Width="{Binding ActualWidth,
RelativeSource={RelativeSource AncestorType={x:Type ScrollContentPresenter}}}"
IsItemsHost="True"
Orientation="Horizontal"
HorizontalAlignment="Left"
>
|
|
|
|
|
Thanks for your suggestion. It's certainly better than I originally had, and I don't quite understand what ScrollContentPresenter has to do with it. But your suggestion only works if I make the containing dialog wider. As I stretch the dialog horizontally, the WrapPanel's width does increase with the width of the dialog and the height of the WrapPanel automatically decreases, but if I make the width of the dialog smaller, the WrapPanel's width and height stays where it was at its widest value and ListBoxItems get truncated to the right within the WrapPanel. What I expected to happen as the dialog width got smaller was the height of the WrapPanel to increase and its width to decrease to accommodate all the ListBoxItems so that they all always remain fully visible.
Perhaps it would help you to find the solution to the remaining problem if you saw my entire XAML file. As you can see, it's actually a UserControl that is used multiple times within a containing dialog.
<UserControl x:Class="CustomControls.HorizontalListBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Loaded="UserControl_Loaded"
>
<Border
BorderThickness="2"
BorderBrush="DarkBlue"
CornerRadius="3"
>
<ScrollViewer
Name="scrollViewer"
MaxHeight="68"
VerticalAlignment="Top"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Hidden"
>
<ListBox
Name="listBox"
BorderThickness="0"
SelectionMode="Extended"
KeyUp="listBox_KeyUp"
SelectionChanged="listBox_SelectionChanged"
>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel
Name="wrapPanel"
MinHeight="17"
Width="{Binding ActualWidth,
RelativeSource=
{RelativeSource AncestorType={x:Type ScrollContentPresenter}}}"
IsItemsHost="True"
Orientation="Horizontal"
HorizontalAlignment="Left"
>
</WrapPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</ScrollViewer>
</Border>
</UserControl>
|
|
|
|
|
I think all you need to set is:
ListBox.HorizontalContentAlignment=Stretch
If that doesn't work then a control containing the UserControl may need that value set as well.
|
|
|
|
|
hb52134214 wrote: ListBox.HorizontalContentAlignment=Stretch
Unfortunately, that doesn't work, and the control containing the UserControl is a Grid, which doesn't take HorizontalContentAlignment. I wonder if there's something missing in the WrapPanel XAML:
<WrapPanel
Name="wrapPanel"
MinHeight="17"
Width="{Binding ActualWidth,
RelativeSource=
{RelativeSource AncestorType={x:Type ScrollContentPresenter}}}"
IsItemsHost="True"
Orientation="Horizontal"
HorizontalAlignment="Left"
>
</WrapPanel>
|
|
|
|
|
Dropping your code directly into a window with a few changes:
<ListBox Name="listBox"
BorderThickness="0"
-> HorizontalAlignment="Stretch"
-> HorizontalContentAlignment="Stretch"
-> ScrollViewer.HorizontalScrollBarVisibility="Disabled"
SelectionMode="Extended">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Name="wrapPanel"
MinHeight="17"
-> HorizontalAlignment="Stretch"
Background="Blue"
IsItemsHost="True"
Orientation="Horizontal"
></WrapPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
Does what I think you're trying to achieve.
If the list box is inside a grid, a grid will default to resize with its container, but the columns may not? In the grid set the column width to '*':
<Grid.COlumndefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
If you have more than one column, do the rest have their widths set to 'auto'?
|
|
|
|
|
Interesting that it's working for you outside of a Grid. You don't even have the ActualWidth binding in the WrapPanel. I took out my binding and added in the WrapPanel HorizontalAlignment to Stretch. It definitely needs the binding. Without that, the ListBoxItems don't even try to wrap properly.
hb52134214 wrote: If the list box is inside a grid, a grid will default to resize with its container, but the columns may not? In the grid set the column width to '*':
The Grid itself does resize with its container (another Grid, which itself is the outer element of the Window). The Grid resizing is working fine, as is the ListBox itself in the third column of its Grid container. The problem is the ListBox.ItemsPanel is not.
I need the first two columns to be hardcoded because they have to line up with columns in another grid beneath the one the UserControl is in. The third column does use *:
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="65"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
So still only a partial solution. If somehow I could get hold of the WrapPanel object, I'd be fat city, because I could just trigger on the width of the dialog. That was my original question: how do I get hold of the WrapPanel, since trying to use its Name ("wrapPanel") doesn't work, probably because it's in an ItemsPanelTemplate. The original reply suggested the ActualWidth binding, but that only half works: expanding the width of the containing window works, but not contracting it. Since I'm saving the width of the window, contracting its width and then restarting it fixes everything, but customers would roll their eyes at that work-around.
|
|
|
|