|
Hmmmm. Downvote countered.
|
|
|
|
|
I have 2 view model in main window
In which i have 1 button in one view model, while in my other view model i have a panel and initially tht panel is visible=fALSE
I want tht while i click on tht button the panel from another view model will be visible
|
|
|
|
|
Well, you could always look at using an EventAggregator.
|
|
|
|
|
Kind of a newbie question. In my XAML I have these 2 lines
<DataGridComboBoxColumn SelectedItemBinding="{Binding ExpenseCategory}" Header="Category" />
<DataGridTextColumn Binding="{Binding ExpenseCategory}" Header="Category"/>
The first one WILL NOT display the value but the second one will. I created the second line to test my sanity [and the binding].
In the viewmodel I've exposed a
List<string> that I had initially bound to the combobox column's ItemsSource. However, when the column failed to display any data I removed it to see if that made a difference. With the List bound to the ItemsSource there was no value for the bound ExpenseCategory property and nothing in the list of values. That XAML was simply:
<DataGridComboBoxColumn SelectedItemBinding="{Binding ExpenseCategory}" ItemsSource="{Binding ExpTypes}" Header="Category"/>
So...what am I missing here? Why won't the combobox column display my data?
|
|
|
|
|
FWIW - and I have no idea if this is even close to an optimal approach - I found this solution in an old article by Julie Lerman http://msdn.microsoft.com/en-us/magazine/gg983481.aspx[^]
<DataGridTemplateColumn Header="Category" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=ExpenseCategory}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<Grid FocusManager.FocusedElement="{Binding ElementName= taskCombo}" >
<ComboBox x:Name="taskCombo" SelectedItem ="{Binding Path=ExpenseCategory}"
IsSynchronizedWithCurrentItem="False"
ItemsSource="{Binding ExpTypes, Source={StaticResource vm}}"/>
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
In her article she explains that the Grid FocusManager is used to manage the events when a new row is created and the user's first click is in the combobox.
This approach seems to work OK, but it is far from straightforward and I hope that somebody here has a better solution that would allow the DataGridComboboxColumn to work for me.
|
|
|
|
|
How about combining the two approaches? Since you've already managed to get the viewmodel into a static resource, something like this should work:
<DataGridComboBoxColumn
SelectedItemBinding="{Binding ExpenseCategory}"
ItemsSource="{Binding ExpTypes, Source={StaticResource vm}}"
Header="Category"
/>
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks for the reply. I've been crawling my way towards that solution by incrementally melding some of the elements of Julie Lerman's approach with a DataGridComboBoxColumn, just hadn't gotten all the way to the one you've suggested. However, I've just tried your code and it works. Much more concise.
Probably should have mentioned in the original question that I'd taken the [non-working] syntax directly from MSDN's latest example for combo box columns, and that had me flummoxed.
|
|
|
|
|
Bonjour,
I'm using Avalondock in my project.
I'm trying to restore a layout saved in a xml file.
All is right.
But hidden Anchorable layout are not showed even if they are defined in a visible layout.
Could you help me ?
Thanks a lot.
|
|
|
|
|
Hello everyone.
I need to have a RichTextBox like input control to use in an application like MS Word. But the challenge is to input text diagonally. Currently I used a RichTextBox and a TextEffect for Runs in Document property of the RichTextBox to show text diagonally and it works. Unfortunately the cursor appears in its original position and direction so the user will be confused what he edit and where he type. Can you help me?
|
|
|
|
|
TextEffect just affects the text. If you apply a RotateTransform to the control, you'll rotate the entire control (including the caret).
|
|
|
|
|
Thank you SledgeHammer01. That's right, but I want to have diagonal lines not diagonal textbox.
|
|
|
|
|
You said you wanted a diagonal textbox. Diagonal input & Diagonal caret???
|
|
|
|
|
I need a portrait style RichTextBox but with diagonal lines (input and display)
|
|
|
|
|
Then you need to put the RichTextBox inside of another border and remove the border from the RichTextBox itself. Then apply the RotateTransform to just the inner RichTextBox. Will give the illusion of a horizontal RichTextBox with diagonal text.
You might also be able to modify the control template of the RichTextControl itself so you don't need the 2nd border.
|
|
|
|
|
I am using this[^] theme.
In the XAML when I use mouse to select some text everything highlights fine. But when I click an element in the design I do not see it highlighted in the XAML. I've searched this in the options but I can't find it.
Anyone know how to change this?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
Hello,
how to make ScrollViewer with non scrollable band on left, or how to make partially non scrollable control?
Thank you.
|
|
|
|
|
I am struggling with the syntax to get the TextTemplate from a static resource.
<Selectors:RuleAttrSelector.TextTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120" />
<ColumnDefinition Width="500" />
</Grid.ColumnDefinitions>
<TextBlock Style="{StaticResource GridCellRight}"
Text="{Binding Path=Label}"
VerticalAlignment="Center" />
<TextBox Grid.Column="1"
Text="{Binding DisplayValue}"
Style="{StaticResource ReadOnlyTextBox}" />
</Grid>
</DataTemplate>
</Selectors:RuleAttrSelector.TextTemplate>
I need this template selector to be reused in multiple forms but cannot work out the correct syntax.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hello,
I ListView Control I filled in a Click bouton.Et what I want is to control the lines of the ListView rows that contain the same elements as in the image below.
here is the link for the image.
http://social.msdn.microsoft.com/Forums/getfile/417417.
this is "Inventory Management" genre ie if a product exists, it increases the amount, if we insert the new quantity but not in a database, but rather in a ListView
I already do this last code to check if there are double lines but it does not work
AddArticleCollection.Add(new ArticleModel {
ID = txtIDProduit.Text,
Design = txtDesigProduit.Text,
Qte = int.Parse(txt_qte_produit.Text),
PrixVente = double.Parse(txtPUProduit.Text)
});
foreach (var item in AddArticleCollection)
{
if (ListVarticle_pr_vend.Items.Contains(item))
{
InfoBox info = new InfoBox("trouvé");
info.ShowDialog();
}
else
{
ListVarticle_pr_vend.Items.Add(item);
}
}
I thank you in advance and sorry for my english twisted.
|
|
|
|
|
Everything is wonderful. Then all of a sudden, it starts throwing exceptions...in the Designer.
The app itself compiles fine, runs fine, I just can't see any of the user controls because of index out of range and the like.
Duh. How can I have an SelectionChanged event coded if it keeps objecting to me using the SelectedIndex property in it?
Yeah, yeah, I know.
But why has it worked fine for months and now it doesn't? Some magic setting somewhere I accidentally set or unset?
VS2012, C#
|
|
|
|
|
I usually find this is an issue for two reasons:
- A (dependency) property on a control is not being set in the default or specified style. This usually happens most on custom controls or controls where I have overridden the default template. Specifying a default value for a property in the default style will usually make this one go away.
- A custom control (or extended control) doesn't handle the binding to a null object correctly. If, for example, you have something bound to a property on a view model but that property is a nullable type, in design mode it will probably be null. When the design surface mocks the VM to present a design-time view, the property evals to null and can throw an exception if the control doesn't handle it properly. If it is a control you wrote/overrode, you can fix it by handling a null value bound to the offending DP. Otherwise, add design-time code to provide a valid value for the offending VM property. (If you are using a framework like MVVMLight, IsInDesignMode is part of the VM base class. Otherwise, System.ComponentModel.DesignerProperties.GetIsInDesignMode will tell you.
Beyond this, good luck. Xaml designer exceptions are especially painful to try to decode. It won't make you feel any better but I've even had the design surface crash repeatedly but clear up after a reboot.
|
|
|
|
|
Yeah. If I do a Clean and then a Rebuild, it displays nicely...for a few minutes, then goes back to not being able to display the controls.
It's just annoying. Of course, any changes I make to the user controls are done on themselves, not on their parent, so it's not a problem as such. Just grrrr. :p
I just can't figure what I could possibly have done to make it stop working after it has been working for so long.
|
|
|
|
|
It usually gives you a pretty damn good hint as to what's wrong. Either in the error dialog or red / blue squiggles. It's entirely possible to have your XAML squiggled without seeing the error dialog. Some people like to ignore those squiggles, but 11 times out of 10, they indicate a real problem.
If you aren't getting an error dialog or squiggles, you can add a global exception handler to your app and pop up a message box, do a full re-build and restart Visual Studio. When it loads your XAML and gets the exception, it'll pop up the message box.
You are probably accessing something that isn't available / initialized yet at design time.
|
|
|
|
|
Yep.
No squiggles, though. And the Stack Traces and Inner Exceptions pointed to all sorts of bizarre places having nothing to do with the actual problem:
App.Current.Windows[0]
App is apparently not available at designtime.
So I wrapped the place it was being used in
<a href="http://www.youtube.com/GenJerDan">YouTube</a>
and
My <a href="http://www.persongo.net/">Mu[sic], Films and Windows Programs, etc.</a>
|
|
|
|
|
I am creating an app that will replace the Linq-To-SQL designer. Most of the code you see is from other apps I found on CP or other places all pieced together.
My app is here[^]. So far there's not much there.
If you run it you will see a mock table on the designer surface. It can be moved around. There is Select checkbox in the upper left corner of the main window. Checking it turns on the table's adorners for sizing.
Problem:
What I want to do is turn on the sizing adorners on the table when the table's header or footer area is clicked. But because both the header & footer border controls have their IsHitTestVisible set to False, the MouseDown even doesn't fire.
I'm not really sure how to make this work. I could use some help.
Many thanks!
If it's not broken, fix it until it is
|
|
|
|
|
I'm not sure the hit test is the problem. I didn't dive in really deep but when you move your mouse over the table, the cursor switches to the cross to indicate moving the table. However, you have to click to move the table. I'm guessing that clicking on the header of the table is actually activating the table move logic... meaning the "move" action is swallowing the click on the header you want.
I suggest moving that table move functionality down. If you want to click on the header and show the size adorners then move the cross/table move functionality down in the visual tree. Or switch to a double-click to show the size adorners. (That would seem more "normal" to me anyway)
HTH!
|
|
|
|