|
Use a DataTrigger and set the visibility based on this.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi ,
I added <Image> // included an image in the window.</Image>
If I wish to add a label just below the image and few other controls, how can i do it? The XAML Code is shown here.
<Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="Auto" Width="Auto" Loaded="Window_Loaded" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
<Image
Name="imgClientPhoto"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Width="auto"
Height="auto"
Grid.Column="0"
Grid.Row="0"
Margin="0" Source="D:\pic1.gif" MinWidth="450" MinHeight="100" Grid.IsSharedSizeScope="True">
</Image>
<Label>
</Label>
</Window>
I added <Label></Label>just below the <Image>
but an error is seen "The property "content" is set more than once.
Please help me to correct this error.
My intention is to add an image at the top(title), then below it a label,then a dropdown box, treeview.. so on..
Please help the good way to work on this.
Thanks Ramm
|
|
|
|
|
You need to put a container into your window to handle multiple items - effectively, the content of your window is the image and you have added extra items immediately after. There are many containers available, e.g. Grid, StackPanel, UniformGrid and so on. The one you use is based on how you want to lay out your interface.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
HI ALL
I was considering and trying to Import sophisticated Designs as Xaml in a Project of WPF
I was Working with AI and also Tried MS Expression Design
==========
1) about AI
I tried to use a Plug-in to export Xaml files, but when you have complicated images it just change that image to a simple image , I had a 3D effect on my Design , but it was simplified by the plug-in i used
and just a very simple image had been made
==========
2) about Expression Design
It didn't have any Effect, the only thing that you have is Gradient, as I saw
and it is not enough to have a professional design
=============
Conclusion: I think The Xaml or at least Xaml Generator are not that powerful to produce complicated, professional designs
================
I want to tell me if it is really rigt or wrong
and if I had mistake in part 1 and/or 2 tell me if there are other tools, plug-ins , and etc
Thank you
Am I banned to write message?
Does anybody see my post?
or is there any problem that I don't get any answer?
modified on Wednesday, July 15, 2009 5:28 AM
|
|
|
|
|
cppwxwidgetsss wrote: I tried to use a Plug-in to export Xaml files, but when you have complicated images it just change that image to a simple image , I had a 3D effect on my Design , but it was simplified by the plug-in i used
and just a very simple image had been made
Expression imports AI files. You need to break them into components to create controls. It doesn't just magically create UI for you. Also, by default it creates a PNG, not XAML, and you should play with the options to create XAML as you need it.
cppwxwidgetsss wrote: It didn't have any Effect, the only thing that you have is Gradient, as I saw
and it is not enough to have a professional design
Expression creates XAML, XAML has gradients, what other effects were you hoping for ?
cppwxwidgetsss wrote: I think The Xaml or at least Xaml Generator are not that powerful to produce complicated, professional designs
A professional design should not be complicated. I've written several programs with WPF, and the UIs on them all are excellent. We had a graphic designer create designs for us in AI, and for one program I skinned with bitmaps, but nowadays I export XAML from AI files. Our designer is given total freedom, which is often a lot of work for me, in terms of non standard shapes etc, but I have NEVER had any trouble turning his screenshots into UI that is identical or better.
cppwxwidgetsss wrote: Am I banned to write message?
Does anybody see my post?
or is there any problem that I don't get any answer?
It's a free website and you posted while the USA ( where most users are ) was asleep. If I was home in Australia, you'd have got a reply. It's now 6 am and I am up early. If you want instant answers, find someone in your timezone you can pay to be on call. Otherwise, you just have to wait until someone replies.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
cppwxwidgetsss wrote: Am I banned to write message?
Unfortunately, no...
cppwxwidgetsss wrote: Does anybody see my post?
Unfortunately, yes.
BTW, set the right country in your profile. It's REAL obvious you're not from the US.
As to your question, you can do pretty much anything you can dream up with WPF. You just have to learn how, and there are no shortcuts in the learning process.
"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 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
cppwxwidgetsss wrote: Conclusion: I think The Xaml or at least Xaml Generator are not that powerful to produce complicated, professional designs
That is not correct - WPF allows you to produce extremely professional designs, perhaps it's your lack of artistic ability that's getting in the way.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Pete O'Hanlon wrote: perhaps it's your lack of artistic ability that's getting in the way.
LOL - as I said, we have a graphic designer, if we didn't, that would sure be our main problem....
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
cppwxwidgetsss wrote: I want to tell me if it is really rigt or wrong
I'm going with wrong.
XAML and XAML generators do NOT produce "complicated, professional designs"...designers do.
In fact, nothing in your post has anything to do with XAML...
You may want to try out Expression Blend 3[^], which supposedly now imports
PSD/AI files preserving the layers and allowing editing in Blend.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I wrote a class inherting from canvas. I added a child inside ItemTemplate.I am having a linkbutton as child. I added it in Page.xaml as
<my:parent><br />
<my:DataPoint Text="30 Members" Link="http://www.zsl.com" ImageUrl="../images/chat.png"></my:DataPoint><br />
</my:parent>
What i want now is,if i change the text or link value it should reflect in design view. Any Idea about this!
Gomathi R
modified on Tuesday, July 14, 2009 5:24 AM
|
|
|
|
|
Hello,
I think it would be better if you can show us some of your code. Otherwise, it's hard for us to help you to solve your problem.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
Microsoft MVP (Silverlight), WPF/Silverlight Insiders
|
|
|
|
|
How can i partially load the controls(combo box, list box) from database, Just like the AJAX's Update panel.
Thanks in advance
|
|
|
|
|
There are numerous ways that you could achieve this, and most of them revolve around using databinding. Take a look at the MVVM pattern to get some ideas (you could start with my SongBird[^] article and look at how I bind and refresh my tabs).
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
hello
i installed the silverlight exe file
when i created the project there was no silverlight file
what happened
|
|
|
|
|
I'm not sure what you are asking.
Silverlight.exe installs the Silverlight runtime. That has nothing
to do with projects.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
install Silverlight2_tools.exe
|
|
|
|
|
|
Don't tie yourself in knots trying to use XAML. Just write code to trigger the animation when you want it to run
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi,
I'm currently struggling with the WPF Toolkit's DataGrid. Well just one aspect to be more accurate. I am displaying the properties of an object in their own columns on the datagrid and each property is bound to a DatagridTextColumn. But if I add a new column after the object has been instanciated and I bind to another property of the object, the binding doesn't work. The datagrid throws a NullRefferenceException. How can I work around this without having to reinstanciate the object?
|
|
|
|
|
can you post your code...
|
|
|
|
|
OK,
This is the XAML for the Datagrid:
<my:DataGrid CanUserAddRows="True" RowHeaderWidth="10" CanUserResizeRows="False" Margin="235,344,38,93" RowHeaderStyle="{StaticResource RowHeaderStyle}" ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}" HeadersVisibility="All" Name="TenderDataGrid" ItemsSource="{Binding Path=TenderLineItems}" AutoGenerateColumns="False" ColumnWidth="SizeToHeader" IsReadOnly="False" SelectionChanged="TenderDataGrid_SelectionChanged" CanUserSortColumns="False" SelectionMode="Single" SelectionUnit="CellOrRowHeader" IsSynchronizedWithCurrentItem="True" Background="#FFDDDDDD" BorderBrush="#FFAAAAAA" BorderThickness="3" AlternatingRowBackground="LightBlue">
<my:DataGrid.Columns>
<my:DataGridTextColumn Header="Series" Binding="{Binding Path=Series, Mode=TwoWay}" Width="Auto"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Item No" Binding="{Binding Path=ItemNo, Mode=TwoWay}"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Description" Binding="{Binding Path=Description, Mode=TwoWay}" MinWidth="200"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Unit" Binding="{Binding Path=Unit, Mode=TwoWay}"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Quantity" Binding="{Binding Path=Qty, Mode=TwoWay}"></my:DataGridTextColumn>
<!--<my:DataGridTextColumn Width="5000"></my:DataGridTextColumn>-->
</my:DataGrid.Columns>
</my:DataGrid>
(Sorry about the indentation)
I have a class that defines an observable collection:
using System.Collections.ObjectModel;
using MMSDLL;
namespace Tender_Module
{
class TenderItemModel
{
public ObservableCollection<ITenderLineItem> TenderLineItems {get;set;}
}
}
This is the interface that I use to be able to add Items to the grid:
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
namespace MMSDLL
{
public interface ITenderLineItem
{
int RateSize { get; set; }
string Series { get; set; }
string Description { get; set; }
string ItemNo { get; set;}
string Unit { get; set; }
double? Qty { get; set; }
double Rate1 { get; set; }
double Rate2 { get; set; }
double Rate3 { get; set; }
double Rate4 { get; set; }
double Rate5 { get; set; }
double Rate6 { get; set; }
double Rate7 { get; set; }
double Rate8 { get; set; }
double Rate9 { get; set; }
double Rate10 { get; set; }
double Rate11 { get; set; }
double Rate12 { get; set; }
double Rate13 { get; set; }
double Rate14 { get; set; }
double Rate15 { get; set; }
double Rate16 { get; set; }
double Rate17 { get; set; }
double Rate18 { get; set; }
double Rate19 { get; set; }
double Rate20 { get; set; }
double Rate21 { get; set; }
double Rate22 { get; set; }
double Rate23 { get; set; }
double Rate24 { get; set; }
double Rate25 { get; set; }
double Rate26 { get; set; }
double Rate27 { get; set; }
double Rate28 { get; set; }
double Rate29 { get; set; }
double Rate30 { get; set; }
double Rate31 { get; set; }
double Rate32 { get; set; }
double Rate33 { get; set; }
double Rate34 { get; set; }
double Rate35 { get; set; }
double Rate36 { get; set; }
double Rate37 { get; set; }
double Rate38 { get; set; }
double Rate39 { get; set; }
double Rate40 { get; set; }
}
}
Then on my main Window where I define the DataGrid, This is the code I use to set the DataContext:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using SYSTEM_LIB_DLL;
using SYSTEM_LIB_DLL.Entity;
using Microsoft.Windows.Controls;
using MMSDLL;
namespace Tender_Module
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
private ObservableCollection<ITenderLineItem> LineItems = new ObservableCollection<ITenderLineItem>();
private TenderItemModel TM;
private Tender InstanceTender;
private const string COMPANY_NAME = "Infrastructure Systems Integrators - Tender Module";
private int seriesPosition = 0;
private string operation;
private RateHandler InstanceRateHandler = null;
public RateHandler CurrentRateHandler
{
get
{
return InstanceRateHandler;
}
set
{
InstanceRateHandler = value;
}
}
public Window1()
{
InitializeComponent();
this.Title = COMPANY_NAME;
TM = new TenderItemModel { TenderLineItems = LineItems };
TenderDataGrid.DataContext = TM;
MainGrid.Visibility = Visibility.Hidden;
}
This is just the first part of a very large class so I'm leaving out the rest of the class and I'll just show the relevant methods that I use:
Now after i've added a few ITenderLineItems to the grid, i want to add new columns to the grid and set their bindings.
private void CreateRateColumns(int numColumns)
{
for (int i = 1; i <= numColumns; i++)// Iterate numColumns
{
DataGridTextColumn RateColumn = new DataGridTextColumn();
Binding theBinding = new Binding("Rate" + i);
RateColumn.Binding = theBinding;
RateColumn.Header = "Rate " + i + " ";
RateColumn.IsReadOnly = false;
TenderDataGrid.Columns.Add(RateColumn);
}
}
This method is relatively straightforward but what happens is that the bindings don't work on the Datagrid after it has been populated with ITenderLineItems instances. If I create the columns before adding these objects to it, then all is well. Now I'm getting a NullReferenceException on the grid if i enter a text value in one of these Dynamicly created columns' cells. I need this grid to adapt to the settings that the user change as long as the program is running. This is quite a thorn in my flesh
|
|
|
|
|
Hi,
I'm newish to threading & asynchronous development so please bear with me if this is a bit of a n00b question. I would like to cache my proxy client object (in my case called DataServiceClient) to prevent constructing the same class over and over with each data read but I'm thinking that doing this in an async architecture could cause problems (playing with Silverlight, not enjoying the learning curve).
When I subscribe to the response event in my cached object, how would I unsubscribe that specific instance of my method call? Subscribing to events do not give you a unique handle for that subscription, and unsubscribing based on method signature could cause problems as I could use the same method for different things...
Could anonymous methods work for this? Do I need to unsubscribe anonymous methods?
How do I manage the user browsing away form my window before my response event fires (rending my data target non-existent)?
Is there a concise article on the web that I need to read before asking this?
(I really wish they would bring sync calls into Silverlight, I have argued with a number of async fans, and I NEED sync calls)
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|
|
Adriaan Davel wrote: When I subscribe to the response event in my cached object, how would I unsubscribe that specific instance of my method call?
Same way you'd unsubscribe to any event.
The "instance" concept depends on how your handler is defined.
If the handler is static, it is a class handler so it has no access to
non-static members of the class the handler is in. When you remove a
static handler from the event, it doesn't matter which one is removed
since there's no object instance associated with the handler. But then
if you're using a static handler, the same delegate typically will only be
added to the event once anyway.
If the handler is non-static, there is an implicit object associated with
the handler that is added to the event, so in a sense, there IS a "a unique
handle for that subscription". When you add a handler, it is added
in the context of an object of the handling class. If you later remove the
handler from the event, only the handler for the removing object will be removed.
Given that, it's up to you to design your code appropriately.
Adriaan Davel wrote: Could anonymous methods work for this? Do I need to unsubscribe anonymous methods?
Yes and yes. Same rules apply. However, an anonymous method would need to be assigned
to a variable for later removal...is it really anonymous any more if you
do that?
Adriaan Davel wrote: How do I manage the user browsing away form my window before my response event fires (rending my data target non-existent)?
Try it. You'll see your handler(s) will never get called.
Adriaan Davel wrote: (I really wish they would bring sync calls into Silverlight, I have argued with a number of async fans, and I NEED sync calls)
Assuming we're talking about calls from the browser here, like to a web service...
If you NEED sync calls, implement them yourself. Simply block on a
WaitHandle (like an EventWaitHandle) until the handler delegate signals
the event. That's a really bad idea in Silverlight, especially if you
block the UI thread. So instead of blocking the UI thread, you might think
"use a worker thread to wait for completion". Well, that gets just as
complex (if not more) as using async calls, doesn't it?
Nobody NEEDS sync calls...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark, again thanks for the reply, quite a bit to work through
I've worked through an example thats very close to sync calls to WCF in Silverlight, but it still would have been much better to be able to do a true sync call from the UI thread. For example, I create a new instance of a class and send it to the WCF service to save it to the SQL database. In my DAL I get the IDENTITY column value after the insert, and use it as a unique Id on the class (also use it for foreign keys etc). The problem is to get the identity value back across the service (with a return value) and assign the value back to the class instance to ensure that I can use the Id on my client.
I've acheived it with the below (rather elaborate) code block (which also needs a bit of work still), but the problem is that this code HAS to run inside my control event, I cannot abstract it from the control and re-use / recall the same code in other controls as the worker thread needs to invoke the UI code else its not sync anymore...
It would have been so easy to just make a sync call, blocking the UI thread till a response is received, and carrying on, just like Win / Web / WPF can do with WCF calls... The whole concept of preventing the developer from blocking the UI thread during data calls is bizarre to me. (In my uneducated opinion Microsoft is trying to make SL UI as cool / fluent as possible for marketing, at huge expense to "normal" programming methods). I love the fact that async calls are so easy to do, and I believe in async calls, but to make sync impossible is bizarre... I always try to write my code to "look like" the business process / logic, and if you are telling a busines that its impossible to make one process wait for the previous to finish, you'll be thrown out...
Anyway, enough complaining, thanks for the usefull comments, much appreciated
string description = txtDescription.Text;
string name = txtName.Text;
ThreadPool.QueueUserWorkItem(delegate
{
InfonMachineActiveDefinition newInfonMachineActiveDefinition = new InfonMachineActiveDefinition { ContainingBranch = GlobalCache.CurrentBranch, Description = description,
Name = name,
CreatedDateTime = DateTime.Now
};
var channelFactory = new ChannelFactory<IDataService>("*");
var dataService = channelFactory.CreateChannel();
var asyncResult = dataService.BeginSaveInfonMachineActiveDefinition(newInfonMachineActiveDefinition, null, null);
try
{
newInfonMachineActiveDefinition.Id = dataService.EndSaveInfonMachineActiveDefinition(asyncResult);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
if (Dispatcher.CheckAccess())
{
Visibility = Visibility.Collapsed;
if (NewInfonMachineActiveDefinitionSaved != null)
NewInfonMachineActiveDefinitionSaved(this, newInfonMachineActiveDefinition);
}
else
Dispatcher.BeginInvoke(delegate
{
Visibility = Visibility.Collapsed;
if (NewInfonMachineActiveDefinitionSaved != null)
NewInfonMachineActiveDefinitionSaved(this, newInfonMachineActiveDefinition);
});
});
____________________________________________________________
Be brave little warrior, be VERY brave
|
|
|
|
|
maybe, I think I don't understand this code.
What wrong if we call like that?
var client = new MyServiceClient();
client.GetDataAsync( (result) => {
textbox.Text = result;
});
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
Microsoft MVP (Silverlight), WPF/Silverlight Insiders
|
|
|
|
|