|
Hi Please go through the zip file of my article the solution for collection class is there.
|
|
|
|
|
U did not perform any search right? u r just binding the listview to the collection .. is n't it ?
|
|
|
|
|
hi,
I have a textbox in which user can enter some text. when user stop typing for a while then it should trigger a method...
If anyone knows the solution please help me..
Aslesh
|
|
|
|
|
I see you found the WPF forum in the end ?
Just set a timer when the user presses a key. Reset it every time they press it, so it only fires when they have not typed for a while.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Thanks Christian.. Its working fine
|
|
|
|
|
Hi
I have an application that needs to capture both Image and Video.
I am using the code that is given on the below link
http://www.codeproject.com/KB/directx/directxcapture.aspx
I m currently using DShowNET to capture images and DirectX.Capture to capture video.If i set preview window its throwing error of
"Could not setup graph.
Value does not fall within the expected range" in the below code.
hr = capGraph.RenderStream(ref cat, ref med, capFilter, null, baseGrabFlt)
The value of hr supposed to come as '0' is coming as some value less than zero.
Thanks in advance to whoever can solve my problem
Manch Manj
|
|
|
|
|
You should really ask this question in the article forum. Also, this is the WPF forum and not the DirectX one.
|
|
|
|
|
Hi
I m new here.Actually I m doing project in WPF only and I m referring DirectX dll to Capture Image and Videos.
If u have any idea about the solution for that error please help me out.
Thanks in advance
Manch Manj
|
|
|
|
|
Hi
I would like to show a 3D mediafile in wpf. But Microsoft hasn't got any player or renderer for it. But I've got other player-applications to show it. So how do I start one of these applications inside a framelike window of a wpf-application?
If it's not possible to actually run an external application inside wpf then I can probably run the external application outside the wpf (but still launch the application from wpf). I found some code to achieve this:
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "abcd.exe"; // set your executable file path
p.Start();
If it's possible to achieve the first solution please provide some code as an example on how. If only solution #2 is possible then is what I wrote in solution #2 correct?
Thanks in advance!
modified on Tuesday, July 8, 2008 3:21 PM
|
|
|
|
|
I’m inheriting from RoutedUICommand and am looking for an elegant and effective way to get parameters to be passed along. How would the XAML owner know that the logon command he’s binding to this click event requires a user name and password?
i know of this way to pass it, but how do "say" you need 2 parameters ( in this case )
CommandParameter="{Binding ElementName=txtUID, Path=Text}"
|
|
|
|
|
I don't think you can have 2 parameters. But if you are actually making a new class that inherits from RoutedUICommand, you could always make DependencyProperties for the Username and Password and bind to those.
|
|
|
|
|
Greetings from my side!
First of all I have to make clear that I'm pretty new to WPF.
I wish to display a matrix of 64x64 items via a gridview/ listview or whatever seems to be appropriate.
I have a class which holds two properties which represent the position inside the grid,
eg.0/1 Row 0, Column 1
Up to64x64 of these items are held inside a Generic List.
Now I want to bind this List and would like to see the elements in their declared cell.
Here's the code so far:
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
List<MatrixElements> elements = new List<MatrixElements>();
for (int i = 0; i < 64; i++)
{
for (int j = 0; j < 64; j++)
{
elements.Add(new MatrixElements(i, j,
string.Format("Element: {0}/{1}", i.ToString(), j.ToString()),
string.Format("ToolTip: {0}/{1}", i.ToString(), j.ToString()),
Colors.Green));
}
}
}
}
public class MatrixElements
{
public int PositionX { get; set; }
public int PositionY { get; set; }
public string Text { get; set; }
public string ToolTip { get; set; }
public Color BackgroundColor { get; set; }
public MatrixElements()
{
}
public MatrixElements(int PositionX, int PositionY, string Text, string ToolTip, Color BackgroundColor)
{
this.PositionX = PositionX;
this.PositionY = PositionY;
this.Text = Text;
this.ToolTip = ToolTip;
this.BackgroundColor = BackgroundColor;
}
}
After all, not all items are existant at the same time which means, that I can have 0/0 0/1 (no 0/2) and 0/3.
My first idea was to override the ListView's Method AddChild(object item), but I found no way how to tell the Grid where to insert the items.
Help would be appreciated, preferable explained with a few lines of code (I know you won't do my "homework" for me, but since I'm new to WPF this would really help a lot).
Thank you in advance,
eza
modified on Tuesday, July 8, 2008 5:01 AM
|
|
|
|
|
I would use a ListBox and set the ItemsPanel property. If you know how many rows and columns you want, you can set the ItemsPanel to a Grid with the appropriate number of RowDefinitions and ColumnDefinitions. Of course, if all the rows and columns will be the same size, you would be better off with a UniformGrid. Once you have that set up, you should be able to just use a data template with attached properties to position the elements.
For example (this code typed in browser with no guarantee of correctness):
<DataTemplate DataType="{x:Type local:MatrixElements}">
<TextBlock Grid.Row="{Binding PositionY}"
Grid.Column="{Binding PositionX}"
Text="{Binding Text}"
ToolTip="{Binding ToolTip}" />
</DataTemplate>
|
|
|
|
|
Thank you for your help. Unfortunately I have to admit that my understanding for WPF is not really existant. So please be so kind a help me a little further.
That's what I tried by now untill I'm stuck again (I know I didn't get that far... but every beginning is kind of hard)
<Window x:Class="TestMatrix.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300"
xmlns:local="clr-namespace:TestMatrix"
>
<Window.Resources>
<DataTemplate DataType="{x:Type local:MatrixElements}">
<TextBlock Grid.Row="{Binding PositinX}"
Grid.Column="{Binding PositionY}"
Text="{Binding Text}"
ToolTip="{Binding ToolTip}"></TextBlock>
</DataTemplate>
</Window.Resources>
<DockPanel>
<UniformGrid x:Name="uGrid" Columns="64" Rows="64">
</UniformGrid>
</DockPanel>
</Window>
I know how to handle this problem the programmatical way:
I inherited my MatrixElement from Textblock and created the Grid by a for i<64 loop to create Column and RowDefinitions. Then I iterated through my list and added the items to the correct grid position.
But after all I would really like to do it in WPF /XAML.
Thank you again for your help, maybe you can spare another few minutes to get me out of this problem.
|
|
|
|
|
I'm not sure why you would need to inherit MatrixElement from TextBlock. For this post, I'll keep the MatrixElement as just a regular class with the properties in your original post. I also ignored the background, because depending on how the background is created in the first case, you may be better off using a trigger. Here's the markup for the window:
<Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfTrash"
Title="Window1" Height="400" Width="600">
<Window.Resources>
<DataTemplate DataType="{x:Type local:MatrixElement}">
<TextBlock Text="{Binding Text}"
ToolTip="{Binding ToolTip}"
HorizontalAlignment="Center" />
</DataTemplate>
</Window.Resources>
<ListBox Name="lstItems" Background="Green">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<Grid Name="grdTest"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="Grid.Row"
Value="{Binding Content.PositionX,
RelativeSource={RelativeSource Self}}" />
<Setter Property="Grid.Column"
Value="{Binding Content.PositionY,
RelativeSource={RelativeSource Self}}" />
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
</Window>
And the code behind (in VB):
Class Window1
Private Sub Window1_Loaded(ByVal sender As Object, _
ByVal e As System.Windows.RoutedEventArgs) _
Handles Me.Loaded
'create some dummy elements and set the items source of the listbox
Dim elems As New List(Of MatrixElement)
Dim curElem As MatrixElement
For r As Integer = 0 To 63
curElem = New MatrixElement
curElem.PositionX = r
curElem.PositionY = r
curElem.Text = String.Format("{0}, {0}", r)
elems.Add(curElem)
Next
lstItems.ItemsSource = elems
'finds the actual grid used by the list box
Dim d As DependencyObject
d = VisualTreeHelper.GetParent( _
lstItems.ItemContainerGenerator.ContainerFromIndex(0))
While Not (d Is Nothing OrElse d.GetType() Is GetType(Grid))
d = VisualTreeHelper.GetParent(d)
End While
If d Is Nothing Then Exit Sub
'once you have the grid, you need to add the rows and columns
Dim rd As RowDefinition
Dim cd As ColumnDefinition
Dim grd As Grid = CType(d, Grid)
lstItems.SetValue(Grid.IsSharedSizeScopeProperty, True)
For i As Integer = 0 To 63
rd = New RowDefinition
rd.Height = New GridLength(1, GridUnitType.Star)
rd.SharedSizeGroup = "MatrixElemRowGroup"
grd.RowDefinitions.Add(rd)
cd = New ColumnDefinition
cd.Width = New GridLength(1, GridUnitType.Star)
cd.SharedSizeGroup = "MatrixElemColumnGroup"
grd.ColumnDefinitions.Add(cd)
Next
'this is just for debugging purposes
grd.ShowGridLines = True
End Sub
End Class
|
|
|
|
|
Thank you for your work, you helped me quite a lot.
I am still struggling with this line of code,
Dim d As DependencyObject
d = VisualTreeHelper.GetParent( _
lstItems.ItemContainerGenerator.ContainerFromIndex(0))
allthough I hope I can get this done.
WPF really is powerful, but at the moment I lack of knowledge how things can/should be done the WPF way.
I use VS2008 and contrary to WinForms, you need another application (namly Blend) to create user-friendly applications -
at least that's my impression.
Thank you once more for your help - I know now, there's still a long road ahead until I can create applications at the same
level like I did it in WinForms.
|
|
|
|
|
I am not sure what about that line of code you are stuck on, but hopefully this article on CodeProject that explains the visual and logical trees can help you. There is a link to another article on the same topic in the comments at the end of the article.
The reason for the first line is that when you do databinding like this, the ListBox.Items property will return the actual MatrixElement instead of the ListBoxItem that is used to draw to the screen. So the line of code you put here is getting the ListBoxItem that is generated for the MatrixElement so I can get into the visual tree. After the item is found, I start walking up the visual tree to find the grid that is generated by the list box, since the only other way to get the rows and columns would be to put the row and column definitions in XAML.
Another thought that came to mind is that the UniformGrid that I suggested earlier will not work for your situation because it ignores the Grid.Row and Grid.Column properties and just places one item after the other. I know that some people use Blend, but so far I have not used Blend and can achieve the same or better results than I did with WinForms. I do use XamlHack when I want to see the default template of a class, but other than that Visual Studio has been enough.
|
|
|
|
|
Hi.
I want to convert rechTextBox's content to HTML code. (in WPF)
How can I do it ?
Do you have a suggestion ?
Freshman
modified on Saturday, July 5, 2008 10:43 PM
|
|
|
|
|
My answer here[^] might help.
|
|
|
|
|
Hi All,
Just trying to launch a help (chm) file from a button in a WPF app. I'm not looking to integrate context sensitivity yet, just plain old show the the file ... anyone done this? I can't seem to find anything on the web that doesn't go into the context sensitivity work.
Cheers,
James.
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Just respond to ApplicationCommands.Help to do this. The following code should help:
static class HelpUtility
{
static HelpUtility()
{
CommandManager.RegisterClassCommandBinding(typeof(FrameworkElement),
new CommandBinding(ApplicationCommands.Help,
new ExecutedRoutedEventHandler(Executed),
new CanExecuteRoutedEventHandler(CanExecute))
);
}
public static string GetHelpKey(DependencyObject dObj)
{
return dObj.GetValue(HelpKeyProperty).ToString();
}
public static void SetHelpKey(DependencyObject dObj, string value)
{
dObj.SetValue(HelpKeyProperty, value);
}
public static readonly DependencyProperty HelpKeyProperty =
DependencyProperty.RegisterAttached("HelpKey",
typeof(string), typeof(HelpUtility));
private static void CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
FrameworkElement fe = sender as FrameworkElement;
if (fe != null)
{
if (HelpUtility.GetHelpKey(fe) != null)
e.CanExecute = true;
}
}
private static void Executed(object sender, ExecutedRoutedEventArgs e)
{
System.Windows.Forms.Help.ShowHelp(null, @"HelpFile.chm",
System.Windows.Forms.Help.HelpNavigator.Index);
}
} Note, if you want to do context sensitive help, then replace the HelpNavigator.Index with HelpUtility.GetHelpKey((FrameworkElement)sender) .
So, to use this you would do something like this:
<... standard window definitions here, but the next bit is the charm
xmlns:help="clr-namespace:...mynamespace...">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefintions>
<RowDefinition />
</Grid.RowDefintions>
<TextBox Grid.Column="0" Grid.Row="0" Name="NameField" help:HelpKey="MyName" />
</Grid>
</Window>
|
|
|
|
|
That's brilliant ... thanks Pete.
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Hi Pete,
Really nice code.
actually i implement this code but i get below error in .xaml file
Error 1 The property 'HelpKey' does not exist in XML namespace 'clr-namespace:TestWPFHelp'. Line 14 Position 107.
and here is my .xaml code
<Window x:Class="TestWPFHelp.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:help="clr-namespace:TestWPFHelp"
Title="Window1" Height="300" Width="300">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<TextBox Grid.Column="1" Height="23" Margin="78,72,80,0" Name="NameFiled" VerticalAlignment="Top" help:HelpKey="MyName" />
</Grid>
</Window>
i m new to wpf and i don't know how i resolve it...
if u have any idea then plz let me know..
Thanks in advance
Krishnraj
|
|
|
|
|
Hi there.
I want to handle Enter key or Space bar key on richTextBox in WPF.
By KeyDawn event I couldn't do it.
Can you help me ?
Freshman
modified on Friday, July 4, 2008 10:43 AM
|
|
|
|
|
What do you mean you want to handle the enter key or space bar? What exactly are you trying to achieve?
|
|
|
|