After much fuss and chasing down events, I was able to get the intended effect on pen, mouse, and touch devices. The following code is not guaranteed to be the best way to accomplish the long click drag, but it is functioning on my devices with Windows 8.1. I encourage...
What an idiot I am! I started to respond to @BradleyDotNET (thanks for the response, by the way. It is what helped me solve the problem), and figured out the solution. My class DOES derive from FrameworkElement. I did that because I needed to make use of data binding, even...
wpf,xaml,modal-dialog,controltemplate,mahapps.metro
Just create your own style that overrides the Template (and don't forget the DialogShownStoryboard) <Style TargetType="{x:Type Dialog:BaseMetroDialog}" x:Key="NewCustomDialogStyle" BasedOn="{StaticResource {x:Type Dialog:BaseMetroDialog}}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Dialog:BaseMetroDialog}"> <ControlTemplate.Resources> <Storyboard x:Key="DialogShownStoryboard"> <DoubleAnimation AccelerationRatio=".9" BeginTime="0:0:0"...
I fixed the problem myself by adding an event handler using AddHandler and using Frame.Navigate to go back to the first page. I added this code: Sub New() AddHandler HardwareButtons.BackPressed, AddressOf BackPressed End Sub Sub BackPressed(sender As Object, e As BackPressedEventArgs) e.Handled = True Frame.Navigate(GetType(BasicPage1)) End Sub ...
Easy peasy with a couple of DataTriggers: <Grid x:Name="LayoutRoot"> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <ListBox Grid.Row="0" ItemsSource="{Binding Currencies}" SelectedItem="{Binding SelectedCurrency, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" DisplayMemberPath="Name" /> <TextBlock FontSize="30" Grid.Row="1"> <TextBlock.Style> <Style TargetType="TextBlock"> <Setter Property="Text" Value="{Binding Price,...
Color is a structure, which means it is passed by value, not by reference. You are basically making copies of the colors, modifying those copies, and then letting them go out of scope and get deleted. You should put the colors into the resource dictionary by doing something along the...
c#,xaml,silverlight,controls,stack-overflow
I stumbled upon that splendid effect myself, and as it turned out: You can't instantiate an object derived from UIElement (your line <local:Control1/> tries exactly this) in a ResourceDictionary (and generic.xaml is one), because all objects in said dictionary must be shareable. Documented here. Relevant section: Shareable Types and UIElement...
StackPanel has a property called as "FlowDirection". Is this what you are looking for? <StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Background="Yellow" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,2,2,0" Name="MainButtonsPanel" Width="400" FlowDirection="RightToLeft"> ...
c#,xaml,mvvm,windows-phone-8.1,prism
You're referring caching here. In the constructor of your ViewModel , set your NavigationCacheMode this.NavigationCacheMode = NavigationCacheMode.Required; and in OnNavigatedTo event handler , check your navigationMode and delete if you're doing something more than default initializing....
It seems to me that your main application namespace is TreeViewTestC and not MyNameSpace. Therefore, you may well need to tell the compiler that your MyNameSpace is actually in the TreeViewTestC assembly, despite you only having a single project. Try using this instead: xmlns:MyTree="clr-namespace:MyNameSpace;assembly=TreeViewTestC" ...
Try using a DataTrigger with predefined DataTemplate items: <DataTemplate x:Key="OneItem" DataType="{x:Type ValueItem}" > <TextBox Text="{TemplateBinding Id}" /> </DataTemplate> <DataTemplate x:Key="MultiItems" DataType="{x:Type ValueItem}" > <ComboBox ItemsSource="{TemplateBinding ValueItems}" DisplayMemberPath="ValueName" SelectedValuePath="ID" SelectedValue="{TemplateBinding Id}" /> </DataTemplate> And then use a Content control to place the style accordingly. I haven't tried this but your data...
Somehow its working fine for me. sharing the code snippet of what I tried. <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <Image Name="img" Height="100" Width="100"/> <TextBox Name="tb3" Text="text2" KeyDown="tb3_KeyDown" Width="200"/> </Grid> <ScrollViewer Grid.Row="2"> <toolkit:WrapPanel Orientation="Vertical" Name="wp"> </toolkit:WrapPanel> </ScrollViewer> Adding textboxes from code behind TextBox tb2 = new TextBox(); // Constructor public MainPage() {...
I finally have gotten the answer to this. Thank you @dub stylee and @Hans Passant I caste the background as a solidcolorbrush then used its color property and compared it to the Windows.Ui.Colors.Green Here is the code. if (((sender as Button).Background as SolidColorBrush).Color != Windows.UI.Colors.Green && ((sender as Button).Background as...
You can use a StringFormat in your binding, like so: <TextBox Text="{Binding ItemName, StringFormat={}Item: {0}}"/> That being said, it may cause some unexpected behavior when editing. For example, if the user edits only the item name (excluding the 'Item:' text), then when the TextBox loses focus, the string format will...
xaml,user-interface,windows-universal,windows-10
Don't use Margins for positioning. Use margins only to enforce margins around the object. To center an element in its parent set its HorizontalAlignment or VerticalAlignment to Center. For more control, use layout controls such as Grid, StackPanel, and RelativePanel to position the controls where you want. For your layout...
This adds a picture to the background of your radio button. myRadioButton.Content = new Image() { Source = (new ImageSourceConverter()).ConvertFrom( "Images/pic.png") as ImageSource }; ...
c#,wpf,xaml,storyboard,styling
Finally worked it out. The code I was looking for was as simple as VisualStateManager.GoToState(HelloWorldButton, "MouseOver", true); ...
Add a Header Style to your DataGrid. <DataGridTemplateColumn Width="200"> <DataGridTemplateColumn.HeaderStyle> <Style TargetType="{x:Type DataGridColumnHeader}"> <Setter Property="HorizontalContentAlignment" Value="Stretch"/> </Style> </DataGridTemplateColumn.HeaderStyle> <DataGridTemplateColumn.HeaderTemplate> ... </DataGridTemplateColumn.HeaderTemplate> ... ...
wpf,xaml,rotation,rendertransform
The problem is that the Transforms were applied after the layout pass. You should use a LayoutTransform to perform the transformation before the layout is calculated: <Image Name="ImageTarget" HorizontalAlignment="Left" VerticalAlignment="Top" Stretch="Uniform" RenderTransformOrigin=".5,.5"> <Image.LayoutTransform> <TransformGroup> <ScaleTransform ScaleX="{Binding Main.BindedViewMode, Converter={StaticResource ImageSizeConverter}}" /> <ScaleTransform ScaleY="{Binding Main.BindedViewMode,...
c#,.net,xaml,windows-phone-8.1
A simple fix would be to set IsFullWindow="True" in your media element property in XAML with this the media element would play in full screen no matter the orientation.(Though its always going to be in landscape mode). You can also set the media element property IsFullWindow as true using C#...
For those who are searching for the solution: BoolToImageConverter.cs: public class BoolToImageConverter : IValueConverter { public object Convert(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) { return (bool)value ? "D:\\Test\\Test\\bin\\Debug\\img\\add.png" : "D:\\Test\\Test\\bin\\Debug\\img\\minus.png"; } public object ConvertBack(object value, System.Type targetType, object parameter, System.Globalization.CultureInfo culture) { return false; // not needed }...
You would need to: public class MainViewModel : ViewModelBase, IBarcodeHandler { public ICollectionView TraceItemCollectionView { get { return CollectionViewSource.GetDefaultView(TraceItemCollectionViewSource); } } public ObservableCollection<TraceDataItem> TraceItemCollectionViewSource { get; set; } } then, somewhere in the code (maybe in the constructor) add your filter: TraceItemCollectionView.Filter = o => { var item = (TraceDataItem)...
I think you should try something like this: foreach (UIElement ball in playArea.Children) { if(ball is ContentControl) ball.Tapped += ball_Tapped; } } void ball_Tapped(object sender, TappedRoutedEventArgs e) { ContentControl ball = sender as ContentControl; double top = Canvas.GetTop(ball); animateBall(ball, top, playArea.ActualHeight, "(Canvas.Top)"); } ...
You could use the always handy FindChild<T> function to retrieve the ScrollContentPresenter inside the ListView, and use your zooming function with it. public Control() { InitializeComponent(); this.Loaded += new RoutedEventHandler(Control_Loaded); } private void Control_Loaded(object sender, RoutedEventArgs e) { var presenter = FindChild<ScrollContentPresenter>(listView, null); var mouseWheelZoom = new MouseWheelZoom(presenter); PreviewMouseWheel +=...
c#,wpf,xaml,datagrid,custom-controls
I had to remove the section from the Generic.xaml style for the DataGrid to properly layout and created the column in code. protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); CloneColumn.Visibility = ShowCloneColumn ? Visibility.Visible : Visibility.Hidden; } private DataGridTemplateColumn _cloneColumn; private DataGridTemplateColumn CloneColumn { get { if (_cloneColumn == null)...
c#,xaml,listview,windows-phone-8.1
You want to change the orientation. <ItemsWrapGrid MaximumRowsOrColumns="2" Orientation="Horizontal"></ItemsWrapGrid> ItemsWrapGrid.Orientation property ...
c#,wpf,xaml,visual-studio-2013
After all the error was my own. I had a third party dll in the solution directly referenced from the Debug folder. Even though the CopyLocal was set to True the dll was not automatically copied in the Release folder. Now I've moved the dll in the Resources folder and...
.net,wpf,xaml,mvvm,data-binding
On your UserControl's code-behind (FilterTraceDataControl.xaml.cs), add a DependencyProperty, like this: public string Text { get { return (string)this.GetValue(TextProperty); } set { this.SetValue(TextProperty, value); } } public static readonly DependencyProperty TextProperty = DependencyProperty.Register( "Text", typeof(string), typeof(FilterTraceDataControl),new PropertyMetadata(null)); Then bind your UserControl's TextBox to it by RelativeSource or ElementName: <TextBox x:Name="PartNumbTextBox" Width="120"...
As there's no code-behind you can't call the method from XAML but need to attach it from the outside: let AboutStack_MouseRightButtonDown args = // do whatever you want, return unit wnd.MouseRightButtonDown.Add(AboutStack_MouseRightButtonDown) or e.g. wnd.MouseRightButtonDown.Add(fun _ -> MessageBox.Show("Click!") |> ignore) Another approach would be to use a model (DataContext) and bindings...
c#,wpf,xaml,listview,windows-runtime
If you have to use ListView then this is how it works: <ListView Margin="120,30,0,120" ItemsSource="{Binding MainViewModel}" Grid.Row="1"> <ListView.View> <GridView> <GridViewColumn DisplayMemberBinding="{Binding Data, Mode=TwoWay}" Width="100" Header="Column 1" /> <GridViewColumn DisplayMemberBinding="{Binding Year, Mode=TwoWay}" Width="100" Header="Column 2" /> <GridViewColumn DisplayMemberBinding="{Binding Month, Mode=TwoWay}" Width="100" Header="Column 3" /> <GridViewColumn...
android,ios,xaml,xamarin,xamarin.forms
You can add a TapGestureRecognizer to the StackLayout in XAML like this: <StackLayout Grid.Column="0" BackgroundColor="#313FA0" Grid.Row="0"> <StackLayout.GestureRecognizers> <TapGestureRecognizer Tapped="OnTapped"/> </StackLayout.GestureRecognizers> </StackLayout> Then you can implement the OnTapped method in the code behind: void OnTapped(object sender, EventArgs e) { // Do stuff } There is a really good guide at the...
wpf,vb.net,xaml,textbox,placeholder
There's nothing wrong with a XAML only solution. <Style TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}" x:Key="TextBoxWithWatermarkStyle"> <Setter Property="Padding" Value="3"/> <Setter Property="Background" Value="White"/> <Setter Property="Foreground" Value="Black"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="TextBox"> <Border BorderThickness="1" CornerRadius="1" Background="{TemplateBinding Background}"> <Grid>...
You give names to elements in xaml by using x:Name, this will cause them to be publicly named in designer generated cs-file (it is made out of xaml) and you can access them as you did it in past in winforms. This code doesn't makes any sense: public partial class...
c#,xaml,winrt-xaml,caliburn.micro,behavior
So the problem is that ActionMessage inherits TriggerAction<FrameworkElement> which means it can't attach correctly to SwipeInteractionBehavior. It's also complicated by the fact there's some major API differences between the WPF / Silverlight / Windows Phone 8 Interactivity SDK and the WinRT Interactivity SDK. You can see a bit of what...
wpf,xaml,data-binding,wpf-controls
Your 'null' item should simply be an item in your collection (of the same type as the rest of the items) that has no properties set, or at least no properties that are displayed. That way, you can avoid the Binding errors all together, because your 'null' item will have...
Unless you need to extend CheckBox for other reasons, what you're trying to do here can be done with Attached Properties too, and it would allow you to have one single Style for all your CheckBoxes. public static class CheckBoxExtensions { public static void SetDefaultValue(CheckBox element, bool value) { element.SetValue(DefaultValueProperty,...
c#,xaml,windows-phone-8,windows-phone-8.1,visualstatemanager
You can write converter to hide/show stackpanel public class BooleanToVisibilityConvertor: IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { if(value!=null) { if (!string.IsNullOrEmpty(value.ToString())) { return Visibility.Visible; } } return Visibility.Collapsed; } public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); }...
c#,wpf,visual-studio,xaml,resourcedictionary
So like I was saying, always make sure you have your build action property set correctly on assets like images you're including in the build. In your case, setting it to Resource does the trick. Glad you got your remedy, cheers!...
You have to set container style: <ListView.ItemContainerStyle> <Style TargetType="ListViewItem"> <Setter Property="VerticalContentAlignment" Value="Top" /> </Style> </ListView.ItemContainerStyle> ...
xaml,caching,windows-store-apps
Does this make sense / improve performance of loading controls? Yes, it does make sense, however there are a few things to consider with this. Probably the most important thing is memory management. You need to consider how much memory you will be using when caching your views. Picture...
Looking at the double click handler source code, it looks like the Width property should be updated. Perhaps something is going wrong in the binding? You might want to make your binding verbose and see what prints in the output window. That issue aside, you may not get the behavior...
c#,xaml,windows-phone-8,windows-phone-8.1,winrt-xaml
Using Converters You can achieve this In xaml <TextBlock x:Name="TB" Text="Text"/> <TextBox Visibility="{Binding ElementName=TB,Path=Text,Converter={StaticResource StringToVisibilityConverter}}"/> And Corresponding converter in c# code is public class StringToVisibilityConverter: IValueConverter { #region IValueConverter Members public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return string.IsNullOrEmpty((string)value)?Visibility.Collapsed:Visibility.Visible; }...
It appears you just have to remove the {}: <system:String x:Key="MyFormat">{0:h\:mm tt}</system:String> The {} is required for attribute values to prevent them from being interpreted as a markup extension. However, with property element syntax, you no longer need the {} because curly braces do not have special meaning in that...
One minor mistake made by you in CustonDatagrid.xaml <DataGrid ItemsSource="{Binding ElementName=CustonDataGrid, Path=Colection}" DockPanel.Dock="Top"></DataGrid> There is no element called CustonDataGrid because of which the elements were never reflected. Changed it to <DataGrid ItemsSource="{Binding Path=Colection}"></DataGrid> I also made minor change in your MainWindow.cs public partial class MainWindow : Window { public MainWindow()...
If you look at the control template for the Button here you can see that it is composed almost entirely of a Border control. Since the Border is what actually took the hit, that is what is being returned. You should use a common helper function to walk up the...
It is not very clear from your question what you are trying to achieve so I will make some assumptions. I think you want get the DataContext of the TabItem where the button was pressed, but you are binding all the buttons to the same click event handler. If I...
c#,wpf,xaml,mvvm,inotifypropertychanged
You are not changing the value of the TestString, you are assigning a command to change the value but you do not seem to be executing it. this.RunCommand = new RelayCommand(this.RunAction); Bind that command to something or execute it manually from somewhere. Also you need to assign the property not...
In order to handle click events in GridView you must set GridView's IsItemClickEnabled property to True and SelectionMode to None. Set a new event handler for ItemClick event and in ItemClickEventArgs parameter (e by default) you can catch the clicked event. (e.ClickedItem) This will give you what Item you clicked...
wpf,xaml,datatemplate,itemssource
You're not binding the Text of the TextBlock to anything. Try something like this: <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Grid.Column="1" Text="{Binding DevDisplay}" /> FYI, the DataTemplate's DataContext is automatically set to the item that it is binding to....
Add a margin or padding to your label like this: <GroupBox Grid.Row="2" Background="LightSteelBlue" Margin="0,-20,0,0" > <GroupBox.Header> <Label FontSize="15" VerticalAlignment="Bottom" FontFamily="Calibri" Padding="0,20,0,0" FontWeight="ExtraBold">Traceability Data</Label> </GroupBox.Header> </GroupBox> Padding seems to give a better results....
Bind the content property of your button to the variable containing the string you want to show - ensuring you explicitly implement INotifyPropertyChanged or use dependency property to update the value: <Button Content={Binding variable_name} /> It is important to know your data context at this point....
xaml,windows-phone-8.1,togglebutton
Please change your XAML to this: <Grid> <ToggleButton x:Name="TogBtn" HorizontalAlignment="Center" VerticalAlignment="Center" Checked="ToggleButton_Checked" Unchecked="ToggleButton_Unchecked"> <SymbolIcon Symbol="Play"></SymbolIcon> </ToggleButton> </Grid> And please add this to your .cs file: private void ToggleButton_Checked(object sender, RoutedEventArgs e) { TogBtn.Content = new SymbolIcon(Symbol.Stop); } private void ToggleButton_Unchecked(object sender, RoutedEventArgs e) { TogBtn.Content = new...
a FocusVisualStyle allows you to provide visual feedback to the user when a control is focused. For example, adding a Rectangle which looks like a border of the control. A Style is the look and feel of the control itself. It's all explained here. FocusVisualStyle is not the style for...
If you don't want any input or hit testing on a certain element you should set the IsHitTestVisible property to false: <Grid> <Canvas Name="Canvas" Background="#EFECCA"> <DockPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Width="{Binding ActualWidth, ElementName=Canvas}" Height="{Binding ActualHeight, ElementName=Canvas}" MouseLeftButtonDown="DockPanel_MouseLeftButtonDown" TouchDown="DockPanel_TouchDown" Panel.ZIndex="2" Background="Transparent"> </DockPanel> <Button Width="50" Height="50"...
Assuming you truly want to have a collapsed visibility in case of null SelectedItem only, there's really no need to use code for that. The following XAML will do the job just fine. Just give your source DataGrid a name (I've assumed Grid as name in following example) and use...
First, you don't need to give different names to your files, use MainPage for both phone and pc project and put MainPage.xaml inside the view folder. The Universal App will be aware of which platforms it runs on and it will load the right page accordingly. You need to create...
c#,xaml,windows-phone,windows-phone-8.1
Your best bet would be describing to Windows.Current.SizeChanged event and testing if width is more than height. There is also a sensor for this, but is is a bit problematic, take a look at http://www.jayway.com/2014/10/06/detecting-orientation-in-universal-apps-windows-phone-8-1/. .xaml <ContentDialog x:Class="App1.ContentDialog1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:App1"...
c#,xaml,mvvm,radio-button,windows-phone-8.1
Assuming that PageState is an enum, this answer is what you're looking for. All of the radio buttons that you want to group together all bind to the same property of the ViewModel and all use the same ValueConverter. The value that triggers a radio button check / uncheck is...
I found a way of doing it, with code behind. I put my Expander in a Canvas and I added to my Expander two events: Expanded="searchMenuExpander_Expanded" and Collapsed="searchMenuExpander_Collapsed" which are defined as: private void searchMenuExpander_Expanded(object sender, RoutedEventArgs e) { Canvas.SetZIndex(searchMenuCanvas, 99); } private void searchMenuExpander_Collapsed(object sender, RoutedEventArgs e) { Canvas.SetZIndex(searchMenuCanvas,...
Here is a simple example: <Window x:Class="CheckboxCheckedCommand.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <CheckBox Content="Case Sensitive" Command="{Binding checkedCommand}"/> </Grid> Codebehind: public partial class MainWindow : Window { public ViewModel vm { get; set; } public MainWindow() { InitializeComponent(); vm = new ViewModel(); this.DataContext = vm; } }...
If you declare a Style without an x:Key, it will override the default style for that control. <Style TargetType="local:CustomControl"> So the code above will effect all CustomControl elements throughout the entire application (or within the scope). If you do not want to override the base style, you can give your...
Does this work...? <DataGrid x:Name="CurrentConfigDataGrid" ItemsSource="{Binding}" > <DataGrid.Resources> <ResourceDictionary Source="../ResourceDictionaries/MergedDictionary.xaml" /> <Style TargetType="TextBlock" BasedOn="{StaticResource {x:Type TextBlock}}" /> </DataGrid.Resources> ... Technically, if you create a Style in your Resources, with no Key but with a TargetType, it should be applied automatically to all controls of that type that have no explicit...
You first attempt is incorrect as the Binding path is relative to the DataContext of the TextBlock. You are trying to bind to a specific element, so you can use ElementName to specify the source and then the path is relative to this: Text="{Binding ElementName=TextBox1, Path=Text}" The idiomatic approach to...
That's because the VisualBrush doesn't have a DataContext. You have to use some proxy element. Define your proxy element: public class DataContextProxy: Freezable { public DataContextProxy() { BindingOperations.SetBinding(this, DataContextProperty, new Binding()); } public object DataContext { get { return GetValue(DataContextProperty); } set { SetValue(DataContextProperty, value); } } public static readonly...
Gridview works fine in Windows Phone apps. Here is code from one of my apps in the app store. You need to set the size of the outer most 'Grid' of the DataTemplate. You won't be able to get the grids to fit the screen exactly unless you do some...
You can add xml:space="preserve" to your resource. This will, like it says, preserve the space. <System:String xml:space="preserve" x:Key="NumStartsTotal">Total: </System:String> More info here and here....
c#,xaml,windows-runtime,winrt-xaml
Depending on what you want achieve, you can just set your UIElement in the Button.Content property. The Button.Content property can accept any UIElement. For example, you can do the following: MainPage.xaml <Page ...> <StackPanel ...> <Button x:Name="myButton" Width="200" Height="200" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" > <Button.Content> <local:Page2 /> </Button.Content> </Button> </StackPanel> </Page> Page2.xaml...
c#,wpf,xaml,binding,commandparameter
<Window x:Class="WpfApplication2.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mine="clr-namespace:WpfApplication2" Title="MainWindow" Height="350" Width="525"> <Grid> <mine:SquareControl Coordinates="{Binding VMCoordinates, Mode=TwoWay}"/> </Grid> </Window> In this case the namespace 'mine' is the namespace of your app. So in the main window the line inside the grid says "Place an instance of SquareControl in my view...
First create a Converter to convert the numeric values to alphabet ones: public class NumericToAlphaConverter:IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { switch (value.ToString()) { case "1": return "A"; case "2": return "B"; case "3": return "C"; case "4": return "D"; case "5": return "E";...
xaml,animation,windows-phone-8,visualstatemanager
The trick is, to define only the visual states, you are interested in. In this case, you are only interested in "pressed" and "normal", so only define those. Here is an example: <Button.Template> <ControlTemplate TargetType="Button"> <ContentPresenter x:Name="LayoutRoot" RenderTransformOrigin="0.5 0.5"> <ContentPresenter.RenderTransform> <ScaleTransform/> </ContentPresenter.RenderTransform> <ContentPresenter.Foreground> <SolidColorBrush Color="White"/> </ContentPresenter.Foreground>...
This is probably what you're looking for: public void PropertyUnchecked(object sender, RoutedEventArgs e) { var item = ((ContentPresenter)((CheckBox)e.Source).TemplatedParent).Content as CheckedListItem<TProperty>; } Edit Passing parameters to PropertyUnchecked (e.g. PropertyUnchecked(object customParam, object sender, RoutedEventArgs e)) was not as easy as I expected because CallMethodAction is very strict on certain signatures and does...
I have find a workaround by using converter: <ListBox x:Name="actionList" Height="150" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MouseMove="ListBoxMouseMove" ScrollViewer.VerticalScrollBarVisibility="Visible" SelectionMode="Extended" Style="{StaticResource CustomListBoxStyle}"> <ListBox.ItemTemplate> <DataTemplate> <TextBlock x:Name="textBlock" Width="235" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" FontSize="11" Text="{Binding DisplayText, Converter={StaticResource...
The solution was the easiest in the world. I need to use the NewsFeedPanel as ItemsPanel instead of a wrapPanel. Thanks Clemens for the suggestion.
c#,xaml,windows-phone-8.1,win-universal-app
You need to yield control to the UI thread to give it a chance to display the progress indicator. One convenient way to do that is to use the async/await keywords: protected override async void OnKeyDown(KeyRoutedEventArgs e) { if (e.Key == Windows.System.VirtualKey.Enter && (xaml_search_box.FocusState == Windows.UI.Xaml.FocusState.Pointer || xaml_search_box.FocusState == Windows.UI.Xaml.FocusState.Keyboard))...
wpf,xaml,binding,windows-phone-8.1
The problem is the use of DataContext. Your MainPage has a DataContext : DataContext="{Binding Main, Source={StaticResource Locator}}" LoadingView also has a DataContext So, when you write this code : You try to find Test2 as a field in the DataContext of the LoadingView because you're in the same View. To...
System.Windows.Documents.Table cannot be hosted with the results you expect by just any container (UserControl in your case). That is why it just calls the ToString() method for displaying purposes, resulting in the string you see. Look into the remarks section of the Table class. It lists suitable parental containers for...
c#,wpf,xaml,mvvm,windows-runtime
You should not notify property changes if the property did not change. You always can know for sure when it becomes empty and the other way around. public string FirstName { get { return this.firstName; } set { if (this.firstName != value) { bool oldValueIsEmpty = String.IsNullOrWhiteSpace(this.firstName); this.firstName = value;...
If you create Assets folder directly in Visual Studio solution, then you can access those assets this way Assests/Images/MyImage.jpg without problems. Don't forget to set Build action to Content.
As Image does not support content, you need to wrap both Image and ComboBox in some kind of container eg. Grid. // set checkbox alignment checkbox.HorizontalAlignment = HorizontalAlignment.Left; checkbox.VerticalAlignment = VerticalAlignment.Bottom; var grid = new Grid(); grid.Children.Add(image); grid.Children.Add(checkbox); ...
c#,wpf,validation,xaml,visual-studio-2012
Using what you posted, it works fine for me, it produces the red "!" above the textbox. However, I DID remember to set my DataContext, ie. public MainWindow() { InitializeComponent(); this.DataContext = this; } Without this, it won't work....
If I understand right your question, you set Name property not in the right place. You should set it for AppBarButton element, not for SymbolIcon. I think your code should work after this changes. CommandBar x:Name="mybar" ClosedDisplayMode="Minimal" > <CommandBar.SecondaryCommands> <AppBarButton Label="setting" Click="AppBarButton_Click"/> </CommandBar.SecondaryCommands> <AppBarButton x:Uid="CALENDAR" x:Name="btnCalendar" Label="calendar" Click="AppBarButton_Click"> <AppBarButton.Icon> <SymbolIcon...
That is not the correct way to register a dependency property. public bool UseCustomTooltips { get { return (bool)GetValue(UseCustomTooltipsProperty); } set { SetValue(UseCustomTooltipsProperty, value); } } public static readonly DependencyProperty UseCustomTooltipsProperty = DependencyProperty.Register("UseCustomTooltips", typeof(bool), typeof(MyControl), new PropertyMetadata(false, new PropertyChangedCallback(MyCallbackMethod))); Use the propdp snippet, it really is a beautiful thing....
StyleSelector doesn't listen to PropertyChange notifications. However you can use DataTrigger based on a Boolean property instead: bool _reelIdChanged; public bool ReelIdChanged { get { return _reelIdChanged; } set { _reelIdChanged = value; RaisePropertyChanged("ReelIdChanged"); } } private string _newReelId; public string NewReelId { get { return _newReelId; } set {...
Add following line into the OnNavigatedFrom method: Windows.Phone.UI.Input.HardwareButtons.BackPressed -= HardwareButtons_BackPressed; In case the OnNavifatedFrom doesn't exist in your partial class of the XAML page, create it like bellow: protected override void OnNavigatedFrom(NavigationEventArgs e) { Windows.Phone.UI.Input.HardwareButtons.BackPressed -= HardwareButtons_BackPressed; } ...
c#,xaml,win-universal-app,universal,windows-media-player
Within Windows Phone 8.0 it was possible to use the Microsoft.Xna.Framework.Media.MediaPlayer to get information (song, album, artist name) about the currently playing songs. WP 8.1, RT and Universal don't provide a way to read this information. It's only possible to write it using the SystemMediaTransportControls. You can vote for this...
I've been tinkering with the solution and I finally found a way to do that. I think the problem is that I didn't understand how ScrollViewer does work. I took the scrolling height as UIElement height hoping for SizeChanged to be fired what isn't truth. ScrollViewer wasn't changing its size...
Your question is very unclear but I'll share some information about ListView. I don't know which facebook app is that but official Facebook App (not beta) is using ListView too AFAIK.You can customize ListView's Style and ItemTemplate to achieve that. Theese 2 MSDN articles about ListView will help you. https://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.controls.listview.aspx...
c#,wpf,xaml,user-interface,datatemplate
I found an answer that will work for my situation right here: http://stackoverflow.com/a/9687758/4912801 It turns out that setting the Panel.ZIndex property wasn't working because WPF inserts a ContentPresenter element for each item in the ItemsControl. In my application, I was trying to get whatever element the mouse is hovering over...
In order to observe changes in a collection WPF provides the ObservableCollection class which implements INotifyCollectionChanged and INotifyPropertyChanged. Replace List<T> with ObservableCollection<T> and your code should work.
c#,xaml,windows-phone-8,progress-bar
Looks like the listed properties have no getter. Make sure to add one before referencing them in the XAML.
I think you're confusing stuff. I assume you want your State items to have a string Measure property, and not a collection of them, but you want to be able to select the Measure value from a Combo with several options... If that's the case, then you should redefine your...
wpf,vb.net,xaml,custom-controls
This is the solution: Public Sub New() MyBase.New() End Sub Shared Sub New() DefaultStyleKeyProperty.OverrideMetadata(GetType(ecTextBox), New FrameworkPropertyMetadata(GetType(ecTextBox))) End Sub ...
c#,xaml,mvvm,binding,winrt-xaml
After hours of searching, I found a StackOverflow answer to a similar question. The answer was to add a PropertyChanged function to the Propertymetadata. I'm not sure yet what this actually means or why it is only needed here, but it works properly: public static readonly DependencyProperty SourceImageResourceIdProperty = DependencyProperty.Register("SourceImageResourceId",...
Ok it works now. I've setted the AncestorType wrong IsEnabled="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}},Path=SelectedItem.ShowBesItemEn}" ...
c#,xaml,slider,windows-phone-8.1,mediaelement
You are setting things up in the wrong order. Try changing it to this: if (listVmItem != null) { var file2 = await _finalStorageFolder.GetFileAsync(listVmItem.FileName); var stream = (await file2.OpenReadAsync()).AsStream().AsRandomAccessStream(); AudioPlayer.MediaOpened += AudioPlayer_MediaOpened; AudioPlayer.CurrentStateChanged += AudioPlayer_CurrentStateChanged; AudioPlayer.SetSource(stream, file2.ContentType); AudioPlayer.Play(); } and move these calls to the MediaOpened handler: TimeSpan recordingTime =...