|
You don't bind UI elements like this. Change the ExternalAlarm property into a boolean (and make it a property, not a field), then use this in your list box ItemTemplate. The ItemTemplate would look something like this:
<DataTemplate x:Key="myItemsTemplate">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30" />
<ColumnDefinition />
<Grid.ColumnDefinitions>
<CheckBox IsChecked="{Binding ExternalAlarm}" Grid.Column="0" />
<TextBlock Text="{Binding ZoneNum}" Grid.Column="1" />
</Grid>
</DataTemplate> Your list box will look like this
<ListBox ItemTemplate="{StaticResource myItemsTemplate}" x:Name="ExternalAlarmTable" />
|
|
|
|
|
Obviously, I'm not getting it. I've been in the embedded world for 25 years. And, some of the Windows programming isn't making sense quite yet. I guess I'll have to get the exact code working before I can analyze each piece before I understand how it works.
I already have a Grid broken down into subgrids. One of the subgrids, I would like to contain this ListBox. How do I incorporate your WPF code into my subgrid? Here is the previous WPF code in which you said my method isn't going to work.
Also, in my C# code, I will populate the ListBox based on the system the user selects. If he selects system 'A', the box will have 5 entries. If he selects system 'B', the box will have 64 entries. That was the previous code I sent you. I can't do it all in WPF.
<DataGrid Grid.Column="0" Grid.Row="1" Height="150" Width="300"
CanUserAddRows="false"
AutoGenerateColumns ="false"
HorizontalAlignment="Left"
RowHeight ="20"
Margin="15,10,0,0"
VerticalAlignment="Top"
Name="ExternalAlarmTable"
CanUserSortColumns="False"
CanUserResizeColumns="False"
CanUserReorderColumns="False"
CanUserResizeRows="False"
SelectionUnit="Cell">
<DataGrid.Columns>
<DataGridTextColumn Header = "Zone #"
Width = "SizeToHeader"
Binding = "{Binding ZoneNum}"
IsReadOnly="true"/>
<DataGridTextColumn Header = "External Alarm Setting"
Binding = "{Binding ExternalAlarm}"
Width="*"/>
</DataGrid.Columns>
</DataGrid>
|
|
|
|
|
OK. I see what you're doing. Right, the problem here is that you are attempting to add a checkbox to a DataGridTextColumn . As I said in my post above, convert ExternalAlarm into a boolean property, and change the DataGridTextColumn into a DataGridCheckBoxColumn .
If you need to implement change notification, so that your display is updated automatically if the ExternalAlarm changes, you'll need to make sure your class implements INotifyPropertyChanged and raise the PropertyChanged event when the value changes in ExternalAlarm .
|
|
|
|
|
Excellent. That's moderately working.
1. How do I position the CheckBoxes at a certain location in the column (like all the way to the left as opposed to in the middle of the column)?
2. If I do the same kind of binding construct for another List of TextMessages and have a class with strings Zone and Text Messages. How do I bind the TextBox to the List? I had that working somewhat and bound the Text Message as a simple string (DataGridTextColumn), but there was no way to restrict the size to 160 characters - like there is with a TextBox. There should be a class DataGridTextBoxColumn, but there is not.
|
|
|
|
|
1. You should be able to set HorizontalAlignment="Left" on the definition of the column.
2. If you need a textbox, all you need to do is put inside DataGridTemplateColumn and put the TextBox inside.
|
|
|
|
|
HorizontalAlignment is not a property that can be used with DataGridCheckBoxColumn.
The TextBox approach with DataGridTemplateColumn worked sortof. Except, it doesn't fill the TextBox with the Binding List until you double click to edit the box. Then, it fills it in properly. How do you get it filled in in prior to entering edit mode?
<DataGrid.Columns>
<DataGridTextColumn
Header = "Zone #"
Width = "SizeToHeader"
Binding = "{Binding ZoneNum}"
IsReadOnly="true"/>
<DataGridTemplateColumn Header="Zone Description Text" Width="*">
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<TextBox Text ="{Binding ZoneDesc}" MaxLength="25"/>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
for (byte i = 0; i < 64; i++)
{
zdentry.Add(new ZoneDescEntry()
{
ZoneNum = "Zone "+(i+1),
ZoneDesc = GlobalVars.User_Parameters.zonedescrip[i]
});
}
ZoneDescTable.ItemsSource = zdentry;
public class ZoneDescEntry
{
public string ZoneNum { get; set; }
public string ZoneDesc { get; set; }
}
|
|
|
|
|
Where do I put
<ListBox ItemTemplate="{StaticResource myItemsTemplate}" x:Name="ExternalAlarmTable" />
It will not compile if it is inside a grid, which I need to do like this.
<Grid Grid.Row="1" Name="EACB" ShowGridLines="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="70"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding ZoneNum}" Grid.Column="0" />
<CheckBox Grid.Column="1" IsChecked="{Binding ExternalAlarm}" />
</Grid>
And, how do I implement my c# back code, if I can't bind UI like you say. See previous reply.
|
|
|
|
|
I'm testing the integration of a user control in the hands of my application wpf, the problem is that my editor is a user control that contains multiple windows forms. I found the xaml code but adding it does not work because the control is composed of several other controls (windows forms, user control ...)
<"Xmlns: myeditor =" clr-namespace.myeditor.EditorForm ">
|
|
|
|
|
hi guys ..
now i start begin work in WP7 for Graduation Project
and the first time use wp7 in this project i need to control desktop of PC via windows phone 7 i need any body to help me how i can do it (control desktop)
and clarify way to right work
plz
|
|
|
|
|
Isn't this your graduation project? It's the chance for you to step up and show that, not only have you learned the basics of writing code, you've also learned how to do research on problems for yourself. It's the chance to really show that you know how to think for yourself and to apply logic and deductive reasoning.
How would I start? Well, I'd research controlling desktops; and I wouldn't limit myself to any existing solution that uses WP7. I'd also make sure that I was familiar with good programming practice in my target platform, and that I was aware of the limitations in that platform.
All I can say is, good luck.
|
|
|
|
|
i begin work in wp7 but i facing problem in control mouse i need tutorial ?
|
|
|
|
|
You don't control a mouse on WP7. It doesn't have one - what it does have is a touch sensitive screen.
|
|
|
|
|
are u have any tutorial about it?
|
|
|
|
|
Did you see that bit in my post earlier about doing research for yourself? Well, that includes being able to find information for yourself - rather than waiting for someone to just give you the answer.
When you leave University, I take it you want to get a job as a developer. How do you think your employer would feel if you couldn't complete a task because you were waiting for someone on a forum to find a tutorial for you? Don't you think that your employer would prefer it if you were able to use tools such as Google to research problems, and find solutions?
The question is, how much do you want to be a good programmer? If you want to be good, you have to be able to research things for yourself. That's an ability that all the top developers have, and it's one you need to pick up if you want to join the elite.
|
|
|
|
|
yes that right the all what u say it's right and thnx so 
|
|
|
|
|
Good luck then. I hope you do well.
|
|
|
|
|
|
Ok i just found the workaround, it is to set IsReadOnly property of the DataGrid to True. Is is good, what could be thw consequences?
|
|
|
|
|
CanUserAddRows is true if DataGrid is not Readonly.
So either set CanUserAddRows or ReadOnly property to false.
"You get that on the big jobs."
|
|
|
|
|
I'm spirits to prepare the design of my application "sending emails" I look for new WPF controls that I can use them, I find some free controls and i thank you I'm still looking
|
|
|
|
|
Do you have a question?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
You can always check out the WPF toolkit[^]. This could contain some controls useful to you.
|
|
|
|
|
This feels like a really dumb question but...
I have a Model which implements OnPropertyChanged on each field in the Model
The ViewModel has an ObservableCollection and SelectedObject of the Model. SelectedObject implements OnPropertyChanged.
When the user changed data in the textbox the Model gets that change event, how do I get the event to the ViewModel vi the SelectedObject
I assume I need to bind an event in the ViewModel to the Model OnChangeEvent. Do I need to add it to each Model as it is selected and remove it as it becomes unselected?
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
In a way, yes. A simple way to do this is to use Observable.FromEvent from the Reactive Extensions.
|
|
|
|
|
Ah research just what I need on a Friday night, nah do it in the morning, me, a couple of beer and some satay are going to get to know each other. Thanks Pete.
Never underestimate the power of human stupidity
RAH
|
|
|
|