|
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
|
|
|
|
|
By default, Metro doesn't know about the desktop (the desktop is just another application which runs from Metro). The reason it works in VS is that VS is already running inside the desktop - so it's not a problem to do this. BTW - how are you trying to run a WPF app from Metro? WPF isn't targetted for Metro - it's the desktop solution.
|
|
|
|
|
We have a middle-tier app that accepts a uri and launches the target app.
Everything makes sense in someone's mind
|
|
|
|
|
Without seeing any code, we can't even begin to guess (although I assume you are using Launcher.LaunchDefaultProgram). Sorry.
|
|
|
|
|
That's exactly what I'm doing.
Everything makes sense in someone's mind
|
|
|
|
|
So how do you get a WPF app to run from metro?
Everything makes sense in someone's mind
|
|
|
|
|
I misread your question, I thought you meant you were trying to launch a WPF from another WPF app running in Metro.
|
|
|
|
|
Anyone have any resources for getting started developing WPF apps on Windows 8? I have been to MSDN and Googled alot, but since Windows 8 is still in preview, there's not alot out there as far as development resources.
Thanks
Everything makes sense in someone's mind
|
|
|
|
|
I am writing code for a WPF application in VS C# Express 2010. I need to use the Windows API code pack for using the 'File Thumbnail handlers' provided by the API. I downloaded and installed the code pack but when I open the WindowsAPICodePack solution in Express, and try to build it, it shows 16 errors. I have put two of them here :
Error 16 Metadata file 'C:\Users\General\Documents\Windows API Code Pack 1.1\Windows API Code Pack 1.1\source\WindowsAPICodePack\Shell\bin\Debug\Microsoft.WindowsAPICodePack.Shell.dll' could not be found
Error 11 The type 'System.Windows.Markup.IQueryAmbient' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Has anyone worked with WindowsAPICodePack in VS Express version? Does it work only with Professional and Ultimate? Please help.
|
|
|
|
|
This looks like the code pack was written in .NET3.5. System.Xaml.dll was introduced in .NET 4, so you need to update your project references to include things like System.Xaml.dll.
|
|
|
|
|
I cannot find System.Xaml in 'References' in VS Express(neither in .Net nor COM). How do I go about doing it? Could you please give more information on that?
Is it doable in the express version?
|
|
|
|
|
Right click on your references, select Add reference. Choose Assemblies from the tablist on the left and make sure that Framework is highlighted. Ensure that your dialog says .NET Framework 4 above the list of assemblies. You may have to wait a little while at first because VS builds up a list of the relevant assemblies and caches them for later use. System.Xaml is just above System.Xml if you have sorted by name.
|
|
|
|