|
Kevin Marois wrote: <i:EventTrigger EventName="ListBoxItem.MouseDoubleClick">
You can't do nested events like that. You can do "MouseDoubleClick" which is going to be the ListBox one. If you want to map to the ListBoxItem one, you have to define a style that targets the ListBoxItem and put it in there.
modified 14-Feb-12 18:03pm.
|
|
|
|
|
That did it.
With the "PassEventArgsToCommand" can't I pass along the Id of the customer I double clicked? if so, how so that done?
I think what I'm missing the code behind. I can't seem to figure it out.
Everything makes sense in someone's mind
|
|
|
|
|
The PassEventArgsToCommand="true" is going to pass the EventArgs object to your command. So you would use RelayCommand<T> where T is the type of event args thrown up by that event. In your case, sender is going to be the ListBoxItem.
|
|
|
|
|
ya, I figured it out. The syntax is new to me, but I got it.
Here's what I have now:
<ListBox x:Name="myListBox"
ItemsSource="{Binding Customers}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick">
<g:EventToCommand Command="{Binding DoubleClickCommand}"
CommandParameter="{Binding SelectedItem, ElementName=myListBox, Mode=OneWay}"
PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
</ListBox>
and it's now passing the double-clicked customer to the handler method.
Truth is, the same could be accomplished by binding the list's SelectedItem.
Thanks!
Everything makes sense in someone's mind
|
|
|
|
|
What exactly are you trying to do?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
...learn how to handle events using MVVM
Everything makes sense in someone's mind
|
|
|
|
|
Kevin Marois wrote: learn how to handle events using MVVM
A generic answer gets a generic response. Your question is beyond a simple forum post. You will most likely have to do some research. There are a couple of approaches. One approach is to use the expression blend libraries as SledgeHammer suggested. Download from codeplex. Or you are going to be writing a bunch of attached behaviors.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
|
I'm trying to figure out how to style my list box items as hyperlinks, but I can't seem to find an example. I don't really know what I'm looking for. Anyone have any example of this?
Thanks
Everything makes sense in someone's mind
|
|
|
|
|
For a hyperlink button, just take a look the HyperLink button.
Here[^] is a sample.
To add hyperlinks to a list, include this in your DataTemplate - here is a very basic code snippet just to get you started.
<DataTemplate>
<Grid>
<HyperLink />
</Grid>
</DataTemplate>
|
|
|
|
|
We have in our application columns wich depend of each others, thats why we wanna them stay together if the user drag a column.
In WPF if you drag a column u see it with low opacity at your mousecursor bevor your drop it, now we would like to see the other column too(wich depend of the draged column) moving with low opacity when the user drag the first column.
Any ideas?
Thanks a lot.
cheers, negada.
|
|
|
|
|
I have a treeview in WPF bound to a list of TreeItemEntity objects:
public class TreeItemEntity : _EntityBase
{
public string Caption { get; set; }
public string Description { get; set; }
public string ImageName { get; set; }
public bool IsExpanded { get; set; }
public TreeItemType ItemType { get; set; }
public List<TreeItemEntity> Children { get; set; }
}
In the XAML I have
<Window.Resources>
<HierarchicalDataTemplate DataType="{x:Type entities:TreeItemEntity}"
ItemsSource="{Binding Path=Children}">
<StackPanel Orientation="Horizontal">
<Image Source="{Binding ImageName}"
Height="16"
Width="16"
Margin="0,0,3,0"/>
<TextBlock Text="{Binding Path=Caption}">
<TextBlock.ToolTip>
<ToolTip>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Label FontWeight="Bold"
Content="{Binding Caption}"/>
<Label Content="{Binding Description}"/>
</StackPanel>
</StackPanel>
</ToolTip>
</TextBlock.ToolTip>
</TextBlock>
</StackPanel>
</HierarchicalDataTemplate>
</Window.Resources>
and
<telerik:RadTreeView x:Name="tvwTree"
Grid.Row="2"
Grid.Column="0"
ItemsSource="{Binding TreeData, Mode=TwoWay}"
SelectedItem="{Binding SelectedTreeItem, Mode=TwoWay}"/>
The question is, how do I bind to the TreeItemEntity's IsExpanded property?
Everything makes sense in someone's mind
|
|
|
|
|
You need to declare a style that targets a TreeViewItem or whatever telerik calls it and bind the IsExpanded in there.
|
|
|
|
|
That did it.
Thanks
Everything makes sense in someone's mind
|
|
|
|
|
I have the following code from inside the UserControl.cs:
public void wait()
{
int i = 0;
while (i < 10)
{
i++;
System.Threading.Thread.Sleep(1000);
}
}
private void IsLoaded(object sender, RoutedEventArgs e)
{
wait();
}
I just want to wait 10 seconds AFTER the layout is rendered(you can see the buttons).
If i execute the code now, it will first wait 10 seconds and then it will render the layout.
I already tried with IsLoaded event for UserControl as you can see in the text and it is not working.
Now, the question I asked was in another context. The real situation is like this:
I have a Window from where I render different(Children.Add(UserControl)) UserControls after doing different calculations in the MainWindow.
The problem is that when I try to update a TextBlock from one of the UserControls by using a Method from the parent Window, the visual update(the text being modified) takes place at the end of the method. And because the operations inside the method takes a few second, a lag between action and display appears.
I have tried: UpdateLayou() after updating but it is not working.
Is there any possible way to render a UserControl immediately after I update one of its fields ?
I need to work using this architecture because I work with Windows Messages in WndProc.
|
|
|
|
|
rdinca wrote: Is there any possible way to render a UserControl immediately after I update one of its fields ?
You can use INotifyPropertyChanged to trigger an update on the UI.
However, on the whole, forcing a delay of 10seconds as the UI is refreshing is really not a good way to code.
You can use an asynchronous call and refresh the UI once the data returns from this call but putting in a delay is not a good practice at all.
|
|
|
|
|
As I told you, the code is just an example made up by me in order to get the question right.
Please read the entire post and if you don't understand what I need I will made up a new example based on the real coding needs.
Thank you,
Adrian
|
|
|
|
|
I have gone through your post.
You should be updating the textbox using Binding and INotifyPropetyChanged (not with a timer).
The UI should update automatically when the end of the method is hit.
Using a timer is not the right way to refresh your UI.
|
|
|
|
|
Sounds like you are doing something VERY wrong...
Adding user controls by hand, updating text boxes by hand, etc.
Sounds like you are writing WPF code in Winforms style... NOT the way to go. Write WPF code in the WPF way and everything will work magically .
|
|
|
|
|
I am trying to get content of a WPF data grid cell using this method:
...objGrid.ItemsSource.Item(<rownumber>).ColumnName
Question is how can I parameterize the columnname instead of having to hardcode it? For example, can I do something like this:
..objGrid.ItemsSource.Item(<rownumber>).Column("<columname">) ????
OR like this..
..objGrid.ItemsSource.Item(<rownumber>).Column("<column number>") ????
I am trying to get away from having to hardcode the columnname. (Long story short, this is for a test automation script that needs to be data driven.)
Any suggestions most welcome!
Thank you!
|
|
|
|
|
But but why are you working on the data via the UI, surely you would work with the bound collection!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Good point, Mycroft However, this is a for a test automation script. The automated test script needs to validate cell values on the grid (UI) as it navigates through the application under test.
There are no failures.. only extended learning opportunities.
|
|
|
|
|
I am not using any image or Ischecked property in left grid in MENU control(WPF). so i want to remove it.
|
|
|
|
|
Get a copy of the menu template. Look for the following code:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="17" SharedSizeGroup="MenuItemIconColumnGroup" Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition SharedSizeGroup="MenuItemIGTColumnGroup" Width="Auto"/>
<ColumnDefinition Width="14"/>
</Grid.ColumnDefinitions>
<ContentPresenter
x:Name="Icon"
ContentSource="Icon"
Margin="4,0,6,0"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="Center"/>
<Path
x:Name="GlyphPanel"
Data="{StaticResource Checkmark}"
Fill="{TemplateBinding Foreground}"
FlowDirection="LeftToRight"
Margin="4,0,6,0"
Visibility="Hidden"
VerticalAlignment="Center"/>
<ContentPresenter
Grid.Column="1"
ContentSource="Header"
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
<Path
Grid.Column="3"
DockPanel.Dock="Right"
Data="{StaticResource RightArrow}"
Fill="{TemplateBinding Foreground}"
Margin="4,0,6,0" VerticalAlignment="Center"/> Change it to
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition SharedSizeGroup="MenuItemIGTColumnGroup" Width="Auto"/>
<ColumnDefinition Width="14"/>
</Grid.ColumnDefinitions>
<ContentPresenter
Grid.Column="0"
ContentSource="Header"
Margin="{TemplateBinding Padding}"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
<Path
Grid.Column="2"
DockPanel.Dock="Right"
Data="{StaticResource RightArrow}"
Fill="{TemplateBinding Foreground}"
Margin="4,0,6,0" VerticalAlignment="Center"/> You will also have to hunt for the Triggers for the Icon and Glyph and remove them.
|
|
|
|
|
I have a WPF app, AppA, that has a button that launches AppB.
When I run it from VS2011 Beta, AppB is opened and switched to desktop. When I run it
from Metro, the app started but does NOT switch to desktop.
Anyone have any thoughts on this?
Everything makes sense in someone's mind
|
|
|
|