 |
|
 |
All WinRT discussions are now in Windows API and WinRT[^]
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
 |
|
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
|
 |
Hello,
I have a popup which is opened on button click.
<Popup Name="MenuPopUp" IsOpen="False" PlacementTarget="{Binding ElementName=dropDownbtn}" Placement="Top" LostFocus="MenuPopUp_LostFocus" MouseLeftButtonDown="MenuPopUp_MouseLeftButtonDown">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<MenuItem Grid.Row="0" Name="ViewReportItem" Header="View Report" Command="{Binding ViewReportCommand}"/>
<MenuItem Grid.Row="1" Name="ExportReportItem" Header="Export Report" Command="{Binding ExportReportCommand}"/>
<MenuItem Grid.Row="2" Name="AbortReportItem" Header="Abort Report" Command="{Binding AbortReportCommand}"/>
</Grid>
</Popup>
I want the popup to stay on screen unless i click somewhere else in the UserControl.
This UserControl is small part of a big UserControl which is working using MVVM and PRISM
How can i do it?
|
|
|
|
 |
|
 |
Hello,
I have a button and a context menu on it.
I want to align the context menu to be opened on top of the button. I mean on the Upper Left corner of the button. How can i do it in XAML?
currently i use the code:
Button Grid.Column="1" BorderThickness="0" Name="dropDownbtn" Click="dropDownbtn_Click" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
<Image Source="/AQUA.ClientServices.Presentation;component/Images/dropDown.png" ClipToBounds="True" />
<Button.ContextMenu>
<ContextMenu BorderThickness="0" Name="LeftClickMenu" MouseLeave="LeftClickMenu_MouseLeave">
<MenuItem Name="ViewReportItem" Header="View Report" Command="{Binding ViewReportCommand}"/>
<MenuItem Name="ExportReportItem" Header="Export Report" Command="{Binding ExportReportCommand}"/>
<MenuItem Name="AbortReportItem" Header="Abort Report" Command="{Binding AbortReportCommand}"/>
</ContextMenu>
</Button.ContextMenu>
</Button>
|
|
|
|
 |
|
 |
The easiest way to do this is to use the ContextMenuService on the button itself. So, in your button definition, add ContextMenuService.Placement="Top"
|
|
|
|
 |
|
 |
OK.
Another issue is that this context menu opened on left mouse click on button.
But it never enters the can_execute .
But when i click Right Mouse Button it does enters can_execute.
How to solve it?
|
|
|
|
 |
|
 |
When I change an instance of an item in a collection, how do I refresh the View without reloading the entire collection?
Right now I'm doing something like:
var temp1 = Products;
Products = null;
Products = temp1;
Callinf RaisePropertyChanged doesn't do it.
Everything makes sense in someone's mind
|
|
|
|
 |
|
 |
I'm a bit confused by your question here. Are you just refreshing an individual property in a single item in the Products list? If so, just raise the PropertyChanged event on that property. Perhaps if you could describe the actual scenario you've got I might be able to offer some more advice.
|
|
|
|
 |
|
 |
Sorry, let me clarify...
I have a list of . If I change a single Product in the list, the item in my tree or list doesn't refresh. Calling RaisePropertyChanged("Products") will refresh the whole collection. To get that to work I have to reload the entore list.
So how do I update the UI so that only the changed item is refreshed?
Everything makes sense in someone's mind
|
|
|
|
 |
|
 |
FYI, you didn't properly encode <ProductModel>, so it doesn't show up (browser thinks it's an HTML tag). To others: he has a list of <ProductModel>.
|
|
|
|
 |
|
 |
Also, perhaps you could use an ObservableCollection? When an item changes, replace that item in the collection.
|
|
|
|
 |
|
 |
If a single item changes in your ProductItem object, simply call RaisePropertyChanged on that item. For instance:public string ProductName
{
get { return productName; }
set
{
if (productName == value) return;
productName = value;
RaisePropertyChanged("ProductName");
}
}If you change the whole item, simply calling RaisePropertyChanged with an empty string will force every bound property in that item to be updated in the binding.
modified yesterday.
|
|
|
|
 |
|
 |
Looks like you've got a PRE penumbra.
|
|
|
|
 |
|
 |
This is what happens when you are typing code comments in VS and the editor at the same time.
|
|
|
|
 |
|
 |
A short time ago, I started learning WPF (with C#). I learned how to create styles and to embed them.
My style contains
<Style x:Key="RoundedButton" TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
<Rectangle Fill="{TemplateBinding Background}" Stroke="Black" RadiusX="8" RadiusY="8"/>
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Background" Value="{StaticResource GreenGradientBrush}"/>
<Style.Triggers>
<Trigger Property="Button.IsFocused" Value="true">
<Setter Property = "Background" Value="{StaticResource RedGradientBrush}"/>
</Trigger>
<Trigger Property="Button.IsMouseOver" Value="true">
<Setter Property = "Background" Value="{StaticResource GoldGradientBrush}"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="AcceptButton" TargetType="{x:Type Button}" BasedOn="{StaticResource RoundedButton}">
<Setter Property="Background" Value="{StaticResource BlueGradientBrush}"/>
<Setter Property="Content" Value="_OK" />
<Setter Property="IsDefault" Value="true" />
</Style>
When I add the AcceptButton to a Window, the underline of "_OK" shows up, and clicking ALT+O does not have any effect.
How can I get the accelerator key working?
|
|
|
|
 |
|
 |
Your template is missing something. Change your ContentPresenter so that you use the access key. All you need to do is add RecognizesAccessKey="True" like this:<ContentPresenter RecognizesAccessKey="True" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
|
|
|
 |
|
 |
Thanks! That did the trick.
|
|
|
|
 |
|
 |
No problem. Glad I could help.
|
|
|
|
 |
|
 |
I have a viewModel which is used to bind to a user control. The user control is basically a AdRotator. One of the feature of AdRotator is that it can be used in multiple positions on same screen. Seperate set of ads will be displayed on these multiple adRotators. The single view model exposes 4 observable collections which is deputed for adRotators on various locations . My problem is that since user controls are 'drag n drop' use i am a looking for a identification method that will let me determine which observablecollection(of the 4) should the an adRotator bind to. Please let me know what are the approaches for this.
Will it be a good approach if i retrieve the name of the user control and bind the collection depending on the name?
|
|
|
|
 |
|
 |
I would change your design approach slightly. There's no need for you to maintain four ObservableCollection properties in your code. In reality, you only need one, and this should be filled based on the choice that needs to be displayed. A simple method to do this would be to use something like an enumeration to define what needs to be loaded, and expose that as a property of your user control.
|
|
|
|
 |
|
 |
in the following XAML:
<UserControl x:Class="NextImage2.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns ="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot">
<Grid.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="Black" Offset="0" />
<GradientStop Color="White" Offset="1" />
</LinearGradientBrush>
</Grid.Background>
<Image Name="image1" Stretch="Fill" Source="file:///C:/Program Files (x86)/Telerik/RadControls for Silverlight Q2 2011/Demos/Examples/Slider/Images/Slider/Image1.PNG" Margin="49,29,0,0" HorizontalAlignment="Left" Width="304" Height="245" VerticalAlignment="Top" />
</Grid>
</UserControl>
the image is displayed in design mode, but is not displayed in runtime, neither in browser nor out of browser.
why it may be?
P.S. replace the face with colon d!
|
|
|
|
 |
|
 |
i found that i didn't add the image to my project. it's just an image which exists somewhere in my HDD.
but, the matter is that i don't want to put a static image there.
consider a program which is written and doesn't intend to know what is the image. by clicking on the default image a file open dialog must be opened from which user may select the image he/she wants to be shown in the Image control.
also consider a case in which the image must be made dynamically. maybe something like a simple MSPaint. user may just draw lines or put points. it's enough that the image not to be static anymore.
what can i do in such cases?
thx
|
|
|
|
 |
|
 |
One of the things to remember when running your application is that it has to respect the permission sets applied, so the fact that you are attempting to read the image from a folder that you will not normally have the permissions to get to is going to cause you a problem.
If your application needs to be able to display an image chosen by the user, a simple way to do this is to read the picture in programatically and display that.
|
|
|
|
 |
|
 |
In my ResourceDictionary I have this
<Style x:Key="BaseControlStyle"
TargetType="UserControl">
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<Style x:Key="CheckBoxStyle"
TargetType="CheckBox"
BasedOn="{StaticResource BaseControlStyle}">
</Style>
The CheckBox is not being vertically centered. If I move the VerticalAlignment setter into the CheckBox style, then it works. Anyone know what I'm doing wrong?
Everything makes sense in someone's mind
|
|
|
|
 |