|
Been messing around with this all day and its not working for some reason. I know as you expand a node, you have to wait for the ItemContainerGenerator to do its thing, which is what I'm doing, but its only expanding one level for some reason:
internal void ExpandAll(TreeViewItem tvi)
{
if (tvi.IsExpanded)
{
for (int nIndex = 0; nIndex < tvi.Items.Count; nIndex++)
{
TreeViewItem tviCurrent = tvi.ItemContainerGenerator.ContainerFromIndex(nIndex) as TreeViewItem;
if ((object)tviCurrent != null)
ExpandAll(tviCurrent);
}
}
else
{
if (tvi.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated)
{
EventHandler handler = null;
handler = new EventHandler(delegate
{
if (tvi.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated)
{
ExpandAll(tvi);
}
});
tvi.ItemContainerGenerator.StatusChanged += handler;
}
tvi.SetCurrentValue(TreeViewItem.IsExpandedProperty, true);
}
}
So I only get inside the EventHandler one time. It doesn't get in there for the child nodes. If I expand the child node manually, THEN the handler code is called.
Also tried the built in .Net ExpandSubTree and it has the same issue. Only expands one level down.
I don't think I'm intercepting anything anywhere.
|
|
|
|
|
I used this article [^]as the basis of my treeview item, it binds the IsExpanded to a property and that drives the tree. I extended it somewhat to meet my needs but it was an excellent concept and worked very well.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Yeah, I have support for binding the IsExpanded property to a property in the data object in my customized TreeView control, but... I dunno... just seems like a hokey requirement to require the user of my control to maintain item state. My custom TreeView control also has built in support for displaying checkboxes next to each item. I can see binding the checkbox to a property in the data object since that kind of seems like a legit requirement. If the user is using checkbox mode, he is going to want to know the checked state of each item. He isn't really going to care about whether a node is expanded or not. Now he *might* if he wants to save the tree state, so I definitely want to keep that as an option, but I was trying to avoid relying on that to make the treeview work in general.
|
|
|
|
|
I have a tag on this discussion at telerik [^]and thought it may be relevant to your issue
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
The WPF toolkit on codeplex has a very good auto complete text box. Just google it as I haven't figured out how to copy paste on my tablet yet, sorry.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Can someone point me to a decent tutorial on how to override a WPF TextBox? I tried Googling, but the answers are all over the board. not sure what I'm looking for. I just want to add various functionality, and I'm looking for a starting point
If it's not broken, fix it until it is
|
|
|
|
|
This MSDN paper[^] explains the basics. You just need to add the parts that are specific to your needs.
Use the best guess
|
|
|
|
|
If you think you need to override a WPF control, you are almost always wrong. WPF allows you to attach behaviour to existing controls using Blend Behaviors.
|
|
|
|
|
Well, Like I said, I'd like to add functionality that's not there, so I don't know how that means I'm wrong. It's really extending the textbox that I want. I just don't know how to do it in WPF.
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
In WPF, it's normal to prefer composition over inheritance. Here's[^] an example of extending the TextBox without actually doing any overriding. This is a very powerful technique.
|
|
|
|
|
How can I limit the length of text entered into a textbox?
I am using WPF Extended Toolkit. Not sure if there's a property on the textbox there to do it.
If it's not broken, fix it until it is
|
|
|
|
|
If there is not a property on the textbox you can always detect the opropertychanged event and deal with it in the VM, you could set up a behaviour (not sure this fires OPC)
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
TextBox has a MaxLength associated with it.
|
|
|
|
|
I have been hearing about Prism. I'm curious how popular it is, and is it worth taking the time to learn. I have heard that it's complex.
1) How many of you are actually using it?
2) Should I start learning it?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
The guys associated with the prism project released a book called 'Developer's Guide to Microsoft Prism'. It was released as a free PDF so don't pay for it unless you want the hardcopy. (Look in the table at the 'Downloads' section on http://msdn.microsoft.com/en-us/library/gg406140.aspx[^]) I suggest you read it even if you don't end up doing anything with Prism.
Prism is the ultimate MVVM toolbox. It has everything which makes it much heavier than something like MVVM Light. Which is why you should read the book and understand the advantages and disadvantages of the framework. In short, where something like MVVM Light is designed to help you build an application that follows the MVVM pattern by providing resources that make the task easier, Prism is designed for building composite applications using the MVVM pattern. That is an important difference.
Like many other frameworks and patterns, you can pick and choose what you want to include so while the whole shooting match is pretty big, you don't have to use all of it. I like it, especially for large projects where the ability to break the resulting app into modules that are located and loaded at runtime provides a big advantage. But I also use MVVM Light a lot as well when I don't need the horsepower Prism provides and I just want the MVVM pattern.
Regardless of whether you ultimately end up using it, you should probably learn about it. At least then you would be able to recognize on your own when it could/should be used rather than relying on the infamous 'I have heard...' decision making process.
|
|
|
|
|
Wow,. Fantastic response. Thank you!!!
If it's not broken, fix it until it is
|
|
|
|
|
The code used in populating combobox is as <DataGridTemplateColumn > <DataGridTemplateColumn.CellTemplate> <DataTemplate >
<ComboBox x:Name="dd" DisplayMemberPath="district" ItemsSource="{Binding Source={StaticResource districtViewSource}}" ></ComboBox> </DataTemplate> </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
THE PROBLEM IS THAT WHEN I SELECT A PARTICULAR ITEM IN COMBO EVERY COMBOBOX IN ABOVE COLUMN IE IN ALL ROWS AUTOMATICALLY SELECTS THAT ITEM. WHILE IT MUST BE ANOTHER ITEM FOR REMAINING ROWS.
|
|
|
|
|
All caps is the equivalent of shouting - very rude!
You are using the same collection districtViewSource for all the combos, create a copy of the collection and a selecteditem for each combo.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hello All,
I have created a webpage and trying to integrate a Silverlight control with it. Unfortunately I am getting an error.
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="Home.aspx.cs" Inherits="OnlineEntertainment.Web.WebForm1" %>
<%@ Register Assembly = "System.Web.Silverlight" Namespace="Syste.Web.UI.SilverlightControls" TagPrefix="asp" %>
<%@ Register Assembly = "AjaxConrolToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Silverlight ID="Silverlight1"
Source="C:\Users\Hunter\Documents\Visual Studio 2010\Projects\OnlineEntertainment\OnlineEntertainment.Web\ClientBin"
runat="Server" Height="805px" Width="623px"> </asp:Silverlight>
</asp:Content>
Element 'Silverlight' is not a known element. This can occur if there is a compilation error in the Web site, or the web.config file is missing.
Is there any specific reason ? I have tried to search for the reference System.Web.Silvelrlight.DLL but it was not present.
I am using Silverlight 5 and Visual Studio 2010.
Thanks and Regards
Anurag
|
|
|
|
|
|
Hello Jason,
I understood your point and tried to modify the source path. However I am wandering that when I am trying to Register the System.Web.Silverlight why I am getting that warning and error. Element Silverlight is not a known element. Web.Config File Missing and all those stuffs.
What I have understood from the link you provided earlier is that there are two controls already shipped with Silverlight 2 SDK. i.e.
Meadia Control and Silverlight Control.
Since this Silverlight Control is not shipped by default with Silverlight 5 SDK I was thinking of that way out. Can you suggest about modifying the web.config file ?
My Modified Code
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="Home.aspx.cs" Inherits="OnlineEntertainment.Web.WebForm1" %>
<%@ Register Assembly = "System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls" TagPrefix="asp" %>
<%@ Register Assembly = "AjaxConrolToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Silverlight ID="Silverlight1" Source="~/ClientBin/OnlineEntertainment.xap" runat="server" Height="805px" Width="623px">
</asp:Silverlight>
<br />
<hr />
<br />
</asp:Content>
Anurag Das
|
|
|
|
|
What's the preferred way to add an event -> ICommand mapping from within a style. I know I can do this use the i:interaction stuff *IF* I'm re-templating. In my case, I do not want to re-template. I just want to add an event handler through the style (because the base style must remain generic). There is no "root" UIElement to add to either. Specifically, I'm trying to handle an event thats coming from the TreeViewItem in my VM. I template the TreeViewItem in my UI Library, but I can't have app specific stuff in there. Don't want to copy the styles over because they are quite large and they really need to remain in the UI library so I don't have to maintain 2 copies.
I've seen some mention of attached behaviors, but it seems like you can only add a single attached command through a style??
|
|
|
|
|
whats the event that you want to handle?
is it selection event?
if it is, then you dont have to goto style for this
<TreeView ......>
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectedItemChanged">
<i:InvokeCommandAction CommandName="ItemSelected" Command="{Binding ItemSelectedCommand}" CommandParameter="{Binding SelectedItem, ElementName=default}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TreeView>
|
|
|
|
|
We're using property grid object in the September release of the Extended Toolkit. We can't upgrade to the latest because they changed some stuff that will break our code. I don't remember exactly what it was, so don't bother asking.
In any case, we have a couple of properties in an object that have the ExpandableObject attribute set. We have an editor template defined that works fine until we try to use it with an ExpandableObject's property. In once instance (a color editor), the template doesn't visually appear at all. In the other (a number up/down), it doesn't appear to be obeying the Min/max values specified in the XAML. Again, BOTH of these templates work fine as long as the property isn't from an ExpandableObject.
Can anyone provide insight?
The docs for the toolkit quite frankly suck as much as documentation can suck, and info regarding the toolkit on the web is - to be kind - sparse.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|