.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

How to show label when TreeView is empty?

Posted By:      Posted Date: September 23, 2010    Points: 0   Category :WPF

Sometimes I feel that DataBinding and Triggers defined in xaml is just trying to fight me.

I have this really simple case where I have a UserControl with a TreeView and a TextBlock. I want to show the TextBlock only when the TreeView is empty.

In code this would be one or two lines of code, but I’m determined to hook it up in xaml, but so far, no matter what I try it doesn’t work.


I even tried to expose the Items as a property on the control class itself – but I could bind to that either.


How would you do this in xaml ?





View Complete Post

More Related Resource Links

TreeView (icon+check+label+textbox) binded to a recursive dataset

Hello dudes, I have a DataSet with a DataTable and I want to populate a TreeView with it's contents:Id, IntParentId, IntName,StringIcon, ???Checked, IntValue, Intthe nodes must look like:   (icon) [checked] - Name |Value|there are 2 fields updatable, checked and value, and changes made by user in the tree must update the datatable/rowI was the last 2 day looking for how to build a tree like this and have no ideas..... tks :)

How show the computer user into a label in a master page

  Hello all, I'm creating a web site and I have this question, I installed a label with the name Userlbl in the master page, and the idea that I have, is when somebody opens the website, the label shows the computer's user, in my case Welcome: "Charly_csh" I tried with this code, that I used before in access and it works, when I load the page on the localhost, but when I load on the server, it shows NETWORK SERVICE The code is this: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Userlbl.Load Dim wshNetwork As Object 'New wshNetwork wshNetwork = CreateObject("WScript.Network") Me.Userlbl.Text = wshNetwork.UserName wshNetwork = Nothing End Sub Does somebody have an idea???       

label inside table inside div won't show

I have a label inside a table cell that is coded to change backcolor conditionally. The table is inside a div tag. The label doesn't appear at runtime. Has anyone experienced this before? Is there a workaround? Thanks. 

Show Calendar Control SQL data value using Label control

Hi, I have a Calendar Control which is getting certain dates from SQL database and shows them in gray colour using following SQL statements: protected void Calendar1_DayRender(object sender, DayRenderEventArgs e) { DateTime nextDate; if (dShows != null) { foreach (DataRow dr in dShows.Tables[0].Rows) { nextDate = (DateTime)dr["Date"]; if (nextDate == e.Day.Date) { e.Cell.BackColor = System.Drawing.Color.DarkGray; } } }  SELECT Count(Mytable.ID), Mytable.Date,MAX(Location.SLocation) as Location FROM Mytable INNER JOIN Location ON Mytable.Sh_ID=Location.Sh_ID GROUP BY Mytable.Date Everything works fine but I want to Show Location and Date also under the calendar control usnig Label control so when user clicks highlighted date it shows Date and Location (only the ones which are coming from SQL database and are highlighted) using Label control. Thank you.      

show value in label on textbox change event

I want to show value in label on textbox change event , means when user enter text in text box then this value should display in label  . I am using this:<asp:UpdatePanel ID="UpdatePanel1" runat="server">    <ContentTemplate>     <asp:TextBox ID="TextBox5" runat="server" ontextchanged="TextBox5_TextChanged" AutoPostBack="true"></asp:TextBox>    </ContentTemplate>    </asp:UpdatePanel>========================================================protected void TextBox5_TextChanged(object sender, EventArgs e)     {         ViewState["xyz"] = Convert.ToInt32(TextBox4.Text) - Convert.ToInt32(TextBox5.Text);         ViewState["xyz1"] = Convert.ToInt32(ViewState["xyz"].ToString()) * 100;         lbldiff.Text = ViewState["xyz"].ToString();         lblprofit.Text = ViewState["xyz1"].ToString();     }protected void TextBox5_TextChanged(object sender, EventArgs e)    {        ViewState["xyz"] = Convert.ToInt32(TextBox4.Text) - Convert.ToInt32(TextBox5.Text);        ViewState["xyz1

How to show the Javascript errors in Label?

Hi,I would like to show the javascript errors in Label,not in some kind of pop up,so the look and feel will be similar to Validation controls,but I dont want to use Validation control.Please view the sample code:<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <title>Untitled Page</title></head><body>    <form id="form1" runat="server">    <div>    <script type="text/javascript">    function makevisible()    {    if (document.getElementById("<%=txt1.ClientID%>").value=="")      {                 alert("Name Feild can not be blank");              //   document.getElementById("<%=txt1.ClientID%>").focus();                 document.getElementById("<%=lblErr.ClientID%>").value="Name can't be blank!";                 return false;  &nb

How can I show Plus sign(Expand mode) Before treeview item in wpf?

Hi,    We are using tree view control in XBAP,in which I m listing all parent node. But it doesnt show plus sign(For expansion) before node header. We have written code to fetch node's child on ItemChanged event.When I click on node and if its have children its showing plus sign.  Do any body know how to show plus sign regardless of whether that node has child or not? Regards, Mehul

Empty WinForm frezzes on show?

Hi! I have a static WindowController where I can do the following : Open LoginForm Open MainForm Open MidiFormInMainForm When application starts it will Open LoginForm with WindowsController. This is done by instanciate the form, binding it to a SuccessfulLogin event and then run Show(). Everything works grate so far. When hitting the login button(in LoginForm) a separate Thread will be created with ThreadPool.QueueUserWorkItem. ThreadPool.QueueUserWorkItem(new WaitCallback(LoginUser)); This Thread will validate the form(with begin invoke), send the login information and if success then trigger the SuccessfulLogin event and finaly close the login(all this from within the LoginForm). When the WindowsController get the SuccessfulLogin event it will run this simple code :   Form form = new Form(); form.Show();   This will open a empty form but it will frezze, it is not even possible to move the window? If we change the code to form.ShowDialog() then it will show properly but we do not want it to be a dialog. I supose that this could have something to do with the threading and maby also that the WindowController is static. Pleas advice. BestRegards  

Treeview populated on demand to show the file system - specifying the root

Hi, I am trying to simulate the file system like explorer using a treeview.  I would like to have the application in the server but is the starting root limited to where the application is?  Is it possible to have a certain directory in the server to be the starting node?  I would like to be able to set a starting node in the config.   Thank you. 

WPF DataGrid does not show new row on empty linq query

I'm using Linq to Entities and bind a linq query to the WPF 4 DataGrid datacontext.  The linq query look something like this:                  var query = from s in this.db.Customers                         orderby s.Name                         select s;             private ContextEntities db = new ContextEntities();             private BindingListCollectionView View;             this.View = ((BindingListCollectionView)CollectionViewSource.GetDefaultView(query));             this.DataContext = this.View; If my Customers table does not have any record, the DataGrid does not show any row for user to add.  I have CanUserAddRows set to true.  I found another post that address this issue but it say to create a new entity type.  http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/cdc0fb6f-2335-42e2-98d7-4bd73ffffc8c My project

Only show text from database if field is not empty

 Hoping someone can help. I am using ASP.NET VB and i am wondering how to only show text from database if data exists. I tried this but it does not work.Any help would be greatly appreciated.I am new to .NET, in the past i have always used classic asp. 1 <td valign="top" style="border-right: 2px solid #031992"> 2 (<%# Eval("VenderPhone1") %>) <%# Eval("VenderPhone2") %>- <%#Eval("VenderPhone3")%> 3 4 <% If String.IsNullOrEmpty(Trim("VenderAlt1").ToString) Then%> 5 <br />(<%#Eval("VenderAlt1")%>) <%# Eval("VenderAlt2") %>- <%#Eval("VenderAlt3")%> 6 <% End If%> 7 <% If String.IsNullOrEmpty(Trim("VenderFax1").ToString) Then%> 8 <br />(<%# Eval("VenderFax1") %>) <%# Eval("VenderFax2") %>- <%#Eval("VenderFax3")%> 9 <% End If%> 10 11 </td> 12   

how to show specific data label or legend in the line chart


I have a line chart with date (X axis) for average numbers. I wanted to show only one number for the month at the chart or legend area. But i can show or hide whole data labels. Is it possible to have an expression box in chart area?

Thanks in advance,


TreeView Empty Leaf cause error


 I have a treeview that shows 'Deals'>DocumentType>DocumentFileName

If there is no documentFileName In a particular DocumentType it causes a javascript error.

How do I avoid this. Thanks.

Imports Microsoft.VisualBasic
Imports System
Imports System.Data
Imports System.Collections
Imports System.Configuration
Imports System.Data.SqlClient
Imports System.Web.UI
Imports System.Web.UI.WebControls
Public Class DealDocs
    ' From http://quickstarts.asp.net/QuickStartv20/util/srcview.aspx?path=~/aspnet/samples/ctrlref/navigation/TreeView/TreeView11.src&file=TreeViewDatabase_vb\App_Code\WarehouseDB.vb&lang=VB+Source

    Public Shared Function GetDocTypes() As doctypeList

        Dim doctypes As New doctypeList

        Dim connStr As String = ConfigurationManager.ConnectionStrings("DB_6056_securedeConnectionString").ConnectionString
        Dim mySource As SqlDataSource = New SqlDataSource(connStr, "procGetDocTypes")
        mySource.SelectCommandType = SqlDataSourceCommandType.StoredProcedure

        Dim result As IEnumerable = mySource.Select(DataSourceSelectArguments.Empty)

        Dim row As DataRowView
        For Each row In result

            doctypes.Add(New doctype( _
                row("DocTypeId").ToString(), _

Show column headers when gridview returns empty data set




I have in my code a gridview that I redirect to excel, it works fine when I have data in the data set. waht I want is to show column headers when there is no data right now what i get is empty sheet. 

TreeView, HierarchicalDataTemplate - How to show sibling collections?


I have an object model (I am using LINQ) that has a HealthCenter as the top level object.  HealthCenter has a Sites collection and a Providers collection. 


Ideally, I want to show this in a TreeView like:


HealthCenter 1


        Site 1


        Site n


        Provider 1


        Provider n


HealthCenter n




I could also live without the Sites and Providers nodes (which are not _really_ part of my objects, just logical) if I had to, as long as I can apply different templates to each type.  So far I've been unable to figure out how to do this.

Show asp:Label from dropdownlist in itemtemplate


Noob working in C# / VS2010.

I have a dropdownlist - ddlGroupName.  Next to it, I have a Label - lblGroupName. 

The dropdownlist is bound to an SQL table, and displays the appropriate group depending on the primary key (contracters, suppliers, etc etc). 

When the page loads, I want the Label to display whatever is in the dropdownlist, then I can hide the dropdownlist and am just left with the label.

I was using "lblGroupName.Text = ddlGroupName.SelectedItem.Text;", but intellisense doesn't seem to acknowledge the controls when they're in an ItemTemplate. 

Any guidance would be very much appreciated....Thank you

Radio buttons, a label and an image button show twice inside update panel


I have an update panel with a set of 2 radio buttons, a label and an image button inside of it. There another set of 3 radio buttons that trigger the update panel. I got everything working but now the image button, label and set of 2 radio buttons inside the update panel show up twice when the radio button triggers are selected? Any ideas?

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend