|
Been trying around a little...
If my data object looks like:
public class MyData : INotifyPropertyChanged
{
private String m_LowChRX;
private String m_LowChTX;
public String LowChRX
{
get { return m_LowChRX; }
set { m_LowChRX = value; OnPropertyChanged("LowChRX"); }
}
public String LowChTX
{
get { return m_LowChTX; }
set { m_LowChTX = value; OnPropertyChanged("LowChTX"); }
}...
In my code I can set the data values in
MyData myData1; And use binding like this
binding = new Binding("LowChRX");
binding.Source = myData1;
myBox.tbLowChRX.SetBinding(TextBox.TextProperty, binding); where myBox is my UC. And, again, I have 6 textboxes in myBox. Then I have to repeat that binding for each textbox. And here is the point where I change from myData1 to other data objects.
If I have a List<String> in my UC, how do I bind it? When then TextBox is a Control, maybe I have to make a custom control inside which hold my List? So I can bind like:
myBox.CustomControl.SetBinding(Property, binding)
Am I on the right track now? 
|
|
|
|
|
You can use Binding with the DependencyProperty.
You can get information on how to implement the DependencyProperty in this blog:
How to Implement a DependencyProperty?
Try with that. It will work.
|
|
|
|
|
WPF gives you a couple options here. I'll just show them in XAML and let you decide what you want and translate to code-behind if you want. All of these examples assume you have an object of type ABC as the DataContext.
Option A - Bind to a specific list with a known key:
<ListBox ItemsSource="{Binding Values[KeyToGetItems]}" />
Option B - Bind to the entire list with another set of controls for the current item:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ListBox Name="lstValues" ItemsSource="{Binding Values}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Key}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel Grid.Row="1" ItemsSource="{Binding SelectedItem.Value, ElementName=lstValues}">
<!-- other controls here -->
</StackPanel>
</Grid>
|
|
|
|
|
Hi All,
I have seen an application which will change the non client area of any windows using in my system. and the application is cristalxp theme.
Now my doubt is along with the application he gave few images which are in png format, Here I would like to expain on image
He has close button image which is simmilar to Vista Close button and in the same image it self he has five more images i.e
one for maximised mouse over,
one for maximised mouse leave,
one for minimized mouse over,
one for minimized mouse leave,
when ever i do some event on the cloe button rexpective image is getting loaded.
I felt that is wow single image with multiple images and loading respectivly.
If some know this logic will you please let me know.
Thanks and Regards
Seshu
|
|
|
|
|
I'm not sure what you're asking here, but AFAIK, there's no support
in PNG for multiple frames in a single image.
The BitmapFrame class can be used as an ImageSource for individual frames
in a multi-frame image if the format supports it (TIFF and GIF in WPF).
So....what are you asking?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
Even I read the same in many forums but Recently i have downloaded an application as such and just as i could upload those images i couldnt show you here.
Any how thanks for your reply and i will get back on this once after having any idea in this regards
<b>Thanks </b>
Seshu
|
|
|
|
|
Overview
WPF Project (VS 2008)
I'm using a ListView (with GridView) bound to an ObservableCollection. The collection includes a DateTime field.
When I populate the collection, the DateNR field is often null, but then the ListView displays a date of "01-Jan-01"!!
How do I stop this as I don't want the user to see a date when there shouldn't be one. I need the DateNR field in the collection to be a DateTime value not a string because this column is used for sorting.
Any ideas would be welcome. thanks
<br />
public class RecordData<br />
{<br />
public int ID { get; set; }<br />
public DateTime DateNR { get; set; }<br />
}<br />
The GridView column for 'DateNR' is specified as follows:
<br />
GridViewColumnHeader gvch = new GridViewColumnHeader();<br />
GridViewColumn gvc = new GridViewColumn();<br />
Binding bind = new Binding("DateNR");<br />
bind.Converter = new FormattingConverter();<br />
bind.ConverterParameter = @"{0:dd-MMM-yy}";<br />
gvc.Width = 80;<br />
gvc.DisplayMemberBinding = bind;<br />
gvch.Content = "NR Date";<br />
gvc.Header = gvch;<br />
myGridView.Columns.Add(gvc);<br />
<br />
SqlConnection sqlConn = new SqlConnection(myConnectionString);<br />
SqlCommand sqlComm = new SqlCommand("...", sqlConn);<br />
SqlDataReader sqlDR = sqlComm.ExecuteReader();<br />
RecordData rd = new RecordData();<br />
rd.ID = sqlDR.GetInt32(0);<br />
if (sqlDR.IsDBNull(1) == false)<br />
rd.DateNR = sqlDR.GetDateTime(1);<br />
_MyCollection.Add(rd);<br />
modified on Saturday, September 19, 2009 5:46 AM
|
|
|
|
|
Hi all.
Can we use XNA physic engines in WPF (2D) ? Is it possible ?
Thanks.
|
|
|
|
|
I almost never write strongly worded posts, but I feel this one is warranted. So I'll go out on a limb and say:
VS2008's ability to reliably update service references in a Silverlight class library project is little more than a crap shoot. The feature is hopelessly broken and has all the appeal of a steaming pile of horse manure. It's a waste of my time to have to exit Visual Studio, reboot, pray or do all of the above in the hope that the reference will actually be imported correctly this time.
Microsoft, if you want developers to seriously consider using Silverlight, I urge you to release a hotfix that addesses this problem. It would be faster to rearchitect our enterprise application's front end in Flash than continue wasting valuable time trying (in vain) to get this to work.
/ravi
Update: Bug 439157[^] filed.
modified on Saturday, May 2, 2009 5:01 PM
|
|
|
|
|
Thanks for filing a bug on Connect!!
I was going to recommend you do that
Also, this is a Visual Studio issue, not a Silverlight issue, so this was
the wrong board to post on
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: Also, this is a Visual Studio issue, not a Silverlight issue,
OK, but it only affects adding a service reference to a Silverlight assembly.
/ravi
|
|
|
|
|
FYI, I've managed to repro the badness and have tracked down what I believe is the offending situation. I'll update the bug report when I have cycles.
/ravi
|
|
|
|
|
Can anyone tell me how to fill a TreeView with items from an Access database in WPF? I've already added my data source; Data >> Add New Data Source in Visual Studio 2008. So my dataset and table adapters are all set up already, just need to get the data into the TreeView. Here's an example of what my tree structure looks like:
>Parts
>Tables
>Top
>Leg
>Chairs
>Seat
>Leg
>Backrest
Table Top, Leg, etc are stored in a 'Parts' table, from which I want to read data.
|
|
|
|
|
This[^] should help.
"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
|
|
|
|
|
How do I create a UserControl which can host other controls? For example, say I wanted to create a UserControl which showed an orange border but could have other controls hosted inside it so:
<my:OrangeBorderThing>
<TextBlock>hello</TextBlock>
</my:OrangeBorderThing>
would show the word "hello" surrounded by an orange border - currentlly I just get the word hello - I have spent a couple of hours reading the usual conflicting things google brings up, messed about with ControlTemplate and ContentPresenter etc but have gotten nowhere.
|
|
|
|
|
<Window x:Class="Wpf2.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Wpf2"
Title="Window1" Height="300" Width="300">
<Grid>
<local:UserControl1 />
</Grid>
</Window>
<UserControl x:Class="Wpf2.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="100" Width="200">
<Grid>
<Border BorderBrush="red" BorderThickness="2">
<TextBlock Text="Hello" />
</Border>
</Grid>
</UserControl>
It woks for me.
Best regards
Agha Khan
|
|
|
|
|
That's not the way it works. What you want is a Style that has your border settings in it, like this:
<Style TargetType="{x:Type Border}" x:Key="MyBorder">
<Setter Property="Background" Value="#E7E3ED" />
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="CornerRadius" Value="8,8,8,8" />
</Style>
and then do this in your UserControl:
<Border Margin="0,31,0,0" Width="222" Height="32" HorizontalAlignment="Left"
VerticalAlignment="Top" Style="{DynamicResource UDPBorder}">
<TextBlock>Hello</TextBlock>
</Border>
"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
|
|
|
|
|
The TextBlock with the content=Hello is just as an example - it could be a grid with lots of other controls inside it. Basicaly I want to write a control that can host other controls. Maybe I am not explaining myself very well - having spent a while on this, tapping random stuff into Google, any sense of what it is I wanted and how to express it has probably been lost.
I think a lot of the problem with this stuff is years ago if you wanted to know what a keyword did in a programming language and how to use it you would look it up in the manual. These days programming language keywords are of little consequence, it's all about the libraries but if you don't know what to look for where exactly do you look?
|
|
|
|
|
Dear John Simmons / outlaw programmer:
Would you please kind enough to look a problem which I posted? All necessary code is there to build the application.
Is this bug is in animation?
Best regards
Agha 
|
|
|
|
|
A better question would be if you even need to make a UserControl. The built in Border control is capable of holding a control as is. If all you are trying to do is have a way to make orange borders, you should just define a style like John suggested and apply it to any borders you want to be orange.
<StackPanel>
<Border Style="{StaticResource OrangeBorderStyle}">
<TextBlock>Hello</TextBlock>
</Border>
<Border Style="{StaticResource OrangeBorderStyle}">
<Grid>
<!-- your controls here -->
</Grid>
</Border>
</StackPanel>
|
|
|
|
|
Would you please kind enough to look "Is this bug in animation?" my problem?
All necessary code is there to build application.
Many thanks
Agha Khan
|
|
|
|
|
Don't post in other threads to try to get people to answer your question.
|
|
|
|
|
You are correct. Thank you to put me in right direction.
Best regards
Agha Khan
|
|
|
|
|
The orange border is of no consequence, it was just as an example. I want a user control which can also host other controls - an item container.
|
|
|
|
|
Try looking at ContentControl (or derived class) along with a style or control template first to see if can meet your needs. If that doesn't work, just create something that derives from ContentControl.
|
|
|
|