|
I overlooked that forum for some reason, probably cosmic radiation on my brain. Thank you for your patient response.
Cheers, --EA
|
|
|
|
|
No problem, but if you got hit by cosmic radiation, does this mean you've developed cool superpowers?
|
|
|
|
|
Only if male pattern baldness and steady memory loss are considered super powers.
|
|
|
|
|
Hi can anyone tell me how to convert this array class object into normal class object, because it is not showing any method like listbox.move or listbox.remove in a listbox associated with this class object//
public partial class Directive : DependencyObject
{
public static readonly DependencyProperty DirectiveIDProperty = DependencyProperty.Register("DirectiveID", typeof(string),
typeof(Directive));
public static readonly DependencyProperty DirectiveNameProperty = DependencyProperty.Register("DirectiveName", typeof(string),
typeof(Directive));
public static readonly DependencyProperty DirectiveDescriptionProperty = DependencyProperty.Register("DirectiveDescription", typeof(string),
typeof(Directive));
public static readonly DependencyProperty PriorityProperty = DependencyProperty.Register("Priority", typeof(string),
typeof(Directive));
public static readonly DependencyProperty DefaultProperty = DependencyProperty.Register("Default", typeof(string),
typeof(Directive));
public static readonly DependencyProperty SetValueTypeProperty = DependencyProperty.Register("SetValueType", typeof(SetValueType),
typeof(Directive));
public static readonly DependencyProperty ConditionProperty = DependencyProperty.Register("Condition", typeof(Condition[]),
typeof(Directive));
public static readonly DependencyProperty GroupProperty = DependencyProperty.Register("Group", typeof(Group[]),
typeof(Directive));
}
because i was using listdata.move and listdata.remove method with normal class object, where listdata is a itemsource name..
here am not finding any method like this, so can u tell me how can i convert this classarray into normal class type..
|
|
|
|
|
I ve no idea what you are talking about. This is a DependencyObject, not an array. What array are you talking about?
|
|
|
|
|
sorry,
My mistake,
Previously i was able to delete the data from listbox Itemsource, which is getting the data from the object of this class..
Now the class structure has been changed, now the itemsource not contaiin a method like remove, move..
it is taking the value into array associated with this class, so can u tell me how can i delete the object values from this class which it contain..
|
|
|
|
|
The class that contains the collection should use an ObservableCollection to contain this type.
|
|
|
|
|
Hi,
Are there any existing written wpf complete sample projects I can download?
Thanks
|
|
|
|
|
Yep, all over the Internet.
|
|
|
|
|
|
something like 101 wpf sample projects.
I searched google but there is nothing similar.
thanks
|
|
|
|
|
|
|
Hello,
I have two listboxes arranged side by side in a Grid control.
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="40" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<ListBox Grid.Column="0" Name="supply" HorizontalAlignment="Stretch" />
<!-- buttons -->
<ListBox Grid.Column="2" Name="select" HorizontalAlignment="Stretch" />
</Grid>
I want both listboxes to have the same width, regardless of the (text) content of the listboxes.
Initially, the left listbox contains a list of strings. The right listbox is empty. If the maximum width of the items in the left listbox is smaller than (roughly) half of the size allocated to the entire grid, everything is ok. Otherwise, the left listbox occupies whatever width is needed to display the widest visible item, and the other list gets the rest.
I suppose that the grid "asks" each listbox what width it wants, and they in turn ask their items. I'd like to stop the process before the width of the items gets involved, IOW both listboxes should report minimal width, then the grid would have plenty of space on its hands, which it would split evenly between the two listboxes.
How can I achieve that ?
I've seen suggestions on the web, involving either SharedSizeGroup or disabling the listbox' horizontal scrollbar and setting HorizontalContentAlignment to "Stretch". They don't seem to work...I also tried binding the left listbox' MaximalWidth the the right listbox' Width, to no avail.
|
|
|
|
|
The code you posted should do exactly what you want.
When you use star-sizing, the grid does NOT resize columns based on child control sizes... First it sets the size of fixed columns (Like your "40"), then it figures out the size of "Auto" columns by asking the controls in those columns what they need, then it splits up the remainder into the star-sized columns.
My suggestions would be:
1) Make sure the grid itself isn't the piece resizing... If it's inside, say, a ScrollViewer, then it'll enlarge itself to (2 x the widest listbox) + 40... It might be the grid itself being cut off on the right, not the second listbox
2) If your actual code is more complex than this (And I suspect it is), try commenting out a piece at a time until you see the behavior you're expecting.
|
|
|
|
|
Ian Shlasko wrote: When you use star-sizing, the grid does NOT resize columns based on child control sizes... First it sets the size of fixed columns (Like your "40"), then it figures out the size of "Auto" columns by asking the controls in those columns what they need, then it splits up the remainder into the star-sized columns.
That's the way I understand it. But I suspect that the listbox in turn examines the items to answer "what it needs".
When I limit the number of characters in the text items for a test, everything works perfectly. So the content of the listbox does matter. I think.
|
|
|
|
|
Except, in the code you posted, the listbox is in a star-sized column, not an Auto column. A star-sized one will always take up a fraction of the remaining width after fixed and auto columns, calculated by dividing its star width by the total star width (1* / (1* + 1*) = 1/2).
Yes, the listbox would resize itself based on its contents, but the grid tells it what rectangle it's supposed to fill, and in this case, that rectangle will have nothing to do with the ListBox contents.
So like I said... Check that the grid itself isn't enlarging, and then try reducing your code until the problem is eliminated (to track down the exact cause).
|
|
|
|
|
Indeed the Grid containing the Listboxes was inside a StackPanel inside a ScrollViewer with HorizontalScrollBarVisibility="Auto". Which caused the problem.
Thanks for helping,
J-L
|
|
|
|
|
You cant do that in XAML, because you need to check which listbox width is higher.
You can add event handler on event which occurs when you already know widths of both listboxes.
For examole: Loaded, Binding.SourceUpdated or smth like this.
Also, if you want to avoid streching of listbox, you have to set colums width="auto":
<ColumnDefinition Width="auto" />
|
|
|
|
|
I created a SL4 application that loads DB from an SQL2K8 server. I want to do it in code.
The grid is initiated as follows:
public MainPage()
{
InitializeComponent();
MTXDomainContext context = new MTXDomainContext();
dataGrid1.ItemsSource = context.compntNames;
context.Load(context.GetCompntNamesQuery());
.
.
.
So my question is:
How can I load just desired columns?
Can I modified the generated code (sample below)to select certain columns?
public IQueryable<compntName> GetCompntNames()
{
return this.ObjectContext.compntNames;
}
Any help is greatly appreciated
|
|
|
|
|
HI,
In my application, i have to do something like that, checking the duplicate of data or checking wether the directive name in my listbox data template is empty or not,
Because when the user click on the button to insert new directive it has to check the listbox like wether the directive name is null or not, so can u tell me how to do it..
I have used a code like this,
public void LoadDirective()
{
listdata = new ObservableCollection<DADirective>();
SelectDirective = (DADirective)lbDirectiveList.SelectedItem;
listdata.Add(new DADirective { DirectiveName = "Filter trading account", DirectiveDescription = "Rows will Trading account value to be filtered" });
listdata.Add(new DADirective { DirectiveName = "Filter Counter party rows", DirectiveDescription = "Rows where counter party is null will be filtered" });
listdata.Add(new DADirective { DirectiveName = "Filter USD currency records", DirectiveDescription = "Filter those rows where currency is USD" });
lbDirectiveList.ItemsSource = listdata;
}
private void btnNewDirectiveClicked(object sender, RoutedEventArgs e)
{
gDirectiveDetails.IsEnabled = true;
gDerivedCondition.IsEnabled = true;
DADirective dirdata = new DADirective { };
if (!listdata.Contains(dirdata))
{
if (listdata.Count >= 0)
{
listdata.Add(new DADirective { });
lbDirectiveList.SelectedIndex = listdata.Count - 1;
txtDirectiveName.Focus();
}
}
}
This is my xaml code..
<ListBox Grid.Row="1" Grid.Column="2" x:Name="lbDirectiveList" ItemsSource="{Binding}" SelectionChanged="lbDirectiveList_SelectionChanged" MaxHeight="200" SelectionMode="Single" ScrollViewer.VerticalScrollBarVisibility="Auto">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Margin="4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="25" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Name="tbDirName" Text="{Binding Path=DirectiveName, Mode=TwoWay}" Grid.Column="0" FontWeight="Bold" MinWidth="200"/>
<TextBlock Text=" - " Grid.Column="1"/>
<TextBlock Grid.Column="2" Name="tbDirDesc" Text="{Binding Path=DirectiveDescription, Mode=TwoWay}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
so how can to read the data in this listbox, i have used a foreach loop like foreach(var dir in listdata), but it is giving exception in case of directive insert, so is there any other way for this...
|
|
|
|
|
Hei you dont need to read the data in the listbox instead you can access the source binded in the ListBox.
lbDirectiveList.ItemsSource
India is Mythical and so we are
|
|
|
|
|
As I told you before[^], you only need to use the ObservableCollection to read the data.
|
|
|
|
|
I need to be able to model and manipulate a 3d graphic base on iges, step or catpart format.
Can somebody show me some example or open source or commercial sdk that allows me to do that.. I need to integrate it in my app.
I really appreciate your help guys..
Rafael
Rafael Tejera
|
|
|
|
|
I have a NumericTextBox control which inherits from TextBox.
It capture key input to only accept valid character, it also have various property such as Min, Max, Precision, etc...
When the Text property is updatde it turns it into a decimal, validate the value and set the "Value" property.
Now, when I consume this item I bind to the "Value" property.
Here lies the problem.
When I update the Value property at InitializeComponent() time (when setting the Precision for example) the Binding on Value is destroyed!
How could I work around this problem?!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|